-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/release/v0.47.x' into ericw/be…
…ginblock-gas-usage-0.47.X
- Loading branch information
Showing
30 changed files
with
403 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,120 @@ | ||
package tx_test | ||
package tx | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/client/tx" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/cosmos/cosmos-sdk/client" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
"github.com/cosmos/cosmos-sdk/crypto/hd" | ||
"github.com/cosmos/cosmos-sdk/crypto/keyring" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig" | ||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" | ||
"github.com/cosmos/cosmos-sdk/crypto/types" | ||
"github.com/cosmos/cosmos-sdk/testutil/testdata" | ||
"github.com/cosmos/cosmos-sdk/types/tx/signing" | ||
|
||
codectypes "github.com/cosmos/cosmos-sdk/codec/types" | ||
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" | ||
) | ||
|
||
func TestFactoryPrepate(t *testing.T) { | ||
func TestFactoryPrepare(t *testing.T) { | ||
t.Parallel() | ||
|
||
factory := tx.Factory{} | ||
factory := Factory{} | ||
clientCtx := client.Context{} | ||
|
||
output, err := factory.Prepare(clientCtx.WithOffline(true)) | ||
require.NoError(t, err) | ||
require.Equal(t, output, factory) | ||
|
||
factory = tx.Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1}).WithAccountNumber(5) | ||
factory = Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1}).WithAccountNumber(5) | ||
output, err = factory.Prepare(clientCtx.WithFrom("foo")) | ||
require.NoError(t, err) | ||
require.NotEqual(t, output, factory) | ||
require.Equal(t, output.AccountNumber(), uint64(5)) | ||
require.Equal(t, output.Sequence(), uint64(1)) | ||
|
||
factory = tx.Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1}) | ||
factory = Factory{}.WithAccountRetriever(client.MockAccountRetriever{ReturnAccNum: 10, ReturnAccSeq: 1}) | ||
output, err = factory.Prepare(clientCtx.WithFrom("foo")) | ||
require.NoError(t, err) | ||
require.NotEqual(t, output, factory) | ||
require.Equal(t, output.AccountNumber(), uint64(10)) | ||
require.Equal(t, output.Sequence(), uint64(1)) | ||
} | ||
|
||
func TestFactory_getSimPKType(t *testing.T) { | ||
// setup keyring | ||
registry := codectypes.NewInterfaceRegistry() | ||
cryptocodec.RegisterInterfaces(registry) | ||
k := keyring.NewInMemory(codec.NewProtoCodec(registry)) | ||
|
||
tests := []struct { | ||
name string | ||
fromName string | ||
genKey func(fromName string, k keyring.Keyring) error | ||
wantType types.PubKey | ||
}{ | ||
{ | ||
name: "simple key", | ||
fromName: "testKey", | ||
genKey: func(fromName string, k keyring.Keyring) error { | ||
_, err := k.NewAccount(fromName, testdata.TestMnemonic, "", "", hd.Secp256k1) | ||
return err | ||
}, | ||
wantType: (*secp256k1.PubKey)(nil), | ||
}, | ||
{ | ||
name: "multisig key", | ||
fromName: "multiKey", | ||
genKey: func(fromName string, k keyring.Keyring) error { | ||
pk := multisig.NewLegacyAminoPubKey(1, []types.PubKey{&multisig.LegacyAminoPubKey{}}) | ||
_, err := k.SaveMultisig(fromName, pk) | ||
return err | ||
}, | ||
wantType: (*multisig.LegacyAminoPubKey)(nil), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := tt.genKey(tt.fromName, k) | ||
require.NoError(t, err) | ||
f := Factory{ | ||
keybase: k, | ||
fromName: tt.fromName, | ||
simulateAndExecute: true, | ||
} | ||
got, err := f.getSimPK() | ||
require.NoError(t, err) | ||
require.IsType(t, tt.wantType, got) | ||
}) | ||
} | ||
} | ||
|
||
func TestFactory_getSimSignatureData(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
pk types.PubKey | ||
wantType any | ||
}{ | ||
{ | ||
name: "simple pubkey", | ||
pk: &secp256k1.PubKey{}, | ||
wantType: (*signing.SingleSignatureData)(nil), | ||
}, | ||
{ | ||
name: "multisig pubkey", | ||
pk: &multisig.LegacyAminoPubKey{}, | ||
wantType: (*signing.MultiSignatureData)(nil), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
got := Factory{}.getSimSignatureData(tt.pk) | ||
require.IsType(t, tt.wantType, got) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"label": "Basics", | ||
"position": 1, | ||
"label": "Beginner", | ||
"position": 2, | ||
"link": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"label": "Core Concepts", | ||
"position": 2, | ||
"label": "Advanced", | ||
"position": 3, | ||
"link": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"label": "Introduction", | ||
"position": 0, | ||
"position": 1, | ||
"link": null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
sidebar_position: 0 | ||
--- | ||
# Learn | ||
|
||
* [Introduction](./intro/00-overview.md) - Dive into the fundamentals of Cosmos SDK with an insightful introduction, | ||
laying the groundwork for understanding blockchain development. In this section we provide a High-Level Overview of the SDK, then dive deeper into Core concepts such as Application-Specific Blockchains, Blockchain Architecture, and finally we begin to explore what are the main components of the SDK. | ||
* [Beginner](./beginner/00-app-anatomy.md) - Start your journey with beginner-friendly resources in the Cosmos SDK's "Learn" | ||
section, providing a gentle entry point for newcomers to blockchain development. Here we focus on a little more detail, covering the Anatomy of a Cosmos SDK Application, Transaction Lifecycles, Accounts and lastly, Gas and Fees. | ||
* [Advanced](./advanced/00-baseapp.md) - Level up your Cosmos SDK expertise with advanced topics, tailored for experienced | ||
developers diving into intricate blockchain application development. We cover the Cosmos SDK on a lower level as we dive into the core of the SDK with BaseApp, Transactions, Context, Node Client (Daemon), Store, Encoding, gRPC, REST, and CometBFT Endpoints, CLI, Events, Telementry, Object-Capability Model, RunTx recovery middleware, Cosmos Blockchain Simulator, Protobuf Documentation, In-Place Store Migrations, Configuration and AutoCLI. |
Oops, something went wrong.