Fully remove StdTx usage in ante handler tests (#6845)

* WIP on removing StdTx from ante handler tests

* Fix recheck

* Fix basic_test

* Don't use StdTx in ante_test

* Use TxConfig sign mode handler in anteHandler

* Fix TestAnteHandlerAccountNumbers

* Amino don't panic

* Fix more tests

* All proto ante tests pass

* Fix last tests

* Amino register concrete

* Add tests

Co-authored-by: Amaury Martiny <amaury.martiny@protonmail.com>
This commit is contained in:
Aaron Craelius
2020-07-29 15:52:22 +00:00
committed by GitHub
co-authored by Amaury Martiny
parent b0c73ae994
commit 9592f34cde
13 changed files with 451 additions and 255 deletions
+8 -19
View File
@@ -18,6 +18,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/rest"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/cosmos-sdk/types/tx/signing"
authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing"
)
@@ -308,25 +309,13 @@ func getSignBytes(
signMode signing.SignMode, signerData authsigning.SignerData,
txBuilder client.TxBuilder, pubKey crypto.PubKey, txConfig client.TxConfig,
) ([]byte, error) {
sigData := signing.SingleSignatureData{
SignMode: signMode,
Signature: nil,
}
sig := signing.SignatureV2{
PubKey: pubKey,
Data: &sigData,
}
// For SIGN_MODE_DIRECT, calling SetSignatures calls SetSignerInfos on
// TxBuilder under the hood, and SignerInfos is needed to generated the
// sign bytes. This is the reason for setting SetSignatures here, with a
// nil signature.
//
// Note: this line is not needed for SIGN_MODE_LEGACY_AMINO, but putting it
// also doesn't affect its generated sign bytes, so for code's simplicity
// sake, we put it here.
if err := txBuilder.SetSignatures(sig); err != nil {
// Set signer info, we only support single signature in this function.
err := txBuilder.SetSignerInfo(pubKey, &txtypes.ModeInfo{
Sum: &txtypes.ModeInfo_Single_{
Single: &txtypes.ModeInfo_Single{Mode: signMode},
},
})
if err != nil {
return nil, err
}
+4
View File
@@ -1,7 +1,10 @@
package client
import (
"github.com/tendermint/tendermint/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing"
"github.com/cosmos/cosmos-sdk/x/auth/signing"
)
@@ -35,6 +38,7 @@ type (
GetTx() signing.SigFeeMemoTx
SetMsgs(msgs ...sdk.Msg) error
SetSignerInfo(pubKey crypto.PubKey, modeInfo *txtypes.ModeInfo) error
SetSignatures(signatures ...signingtypes.SignatureV2) error
SetMemo(memo string)
SetFeeAmount(amount sdk.Coins)