Update ante handler unit tests

This commit is contained in:
Aleksandr Bezobchuk
2018-08-31 16:44:34 -04:00
parent e2c0645a10
commit e83a2b97f9
5 changed files with 177 additions and 206 deletions
+1 -20
View File
@@ -40,7 +40,7 @@ func NewTestStdFee() auth.StdFee {
}
func NewTestStdTx(
chainID *big.Int, msgs []sdk.Msg, accNums []int64, seqs []int64, pKeys []*ecdsa.PrivateKey, fee auth.StdFee,
chainID *big.Int, msgs []sdk.Msg, accNums, seqs []int64, pKeys []*ecdsa.PrivateKey, fee auth.StdFee,
) sdk.Tx {
sigs := make([]auth.StdSignature, len(pKeys))
@@ -100,22 +100,3 @@ func NewTestEthTxs(
return txs
}
func NewTestSDKTxs(
codec *wire.Codec, chainID *big.Int, to ethcmn.Address, msgs []sdk.Msg,
accNums []int64, seqs []int64, pKeys []*ecdsa.PrivateKey, fee auth.StdFee,
) []*Transaction {
txs := make([]*Transaction, len(pKeys))
stdTx := NewTestStdTx(chainID, msgs, accNums, seqs, pKeys, fee)
payload := codec.MustMarshalBinary(stdTx)
for i, privKey := range pKeys {
ethTx := NewTransaction(uint64(seqs[i]), to, big.NewInt(10), 1000, big.NewInt(100), payload)
ethTx.Sign(chainID, privKey)
txs[i] = ethTx
}
return txs
}
+4 -6
View File
@@ -120,16 +120,14 @@ func TestTxDecoder(t *testing.T) {
require.Equal(t, txs[0].data, (decodedTx.(Transaction)).data)
// create a SDK (auth.StdTx) transaction and encode
txs = NewTestSDKTxs(
testCodec, TestChainID, TestSDKAddr, msgs, []int64{0}, []int64{0},
[]*ecdsa.PrivateKey{TestPrivKey1}, NewTestStdFee(),
)
stdTx := NewTestStdTx(TestChainID, msgs, []int64{0}, []int64{0}, []*ecdsa.PrivateKey{TestPrivKey1}, NewTestStdFee())
payload := testCodec.MustMarshalBinary(stdTx)
tx := NewTransaction(0, TestSDKAddr, big.NewInt(10), 1000, big.NewInt(100), payload)
txBytes, err = rlp.EncodeToBytes(txs[0])
txBytes, err = rlp.EncodeToBytes(tx)
require.NoError(t, err)
// require the transaction to properly decode into a Transaction
stdTx := NewTestStdTx(TestChainID, msgs, []int64{0}, []int64{0}, []*ecdsa.PrivateKey{TestPrivKey1}, NewTestStdFee())
decodedTx, err = txDecoder(txBytes)
require.NoError(t, err)
require.IsType(t, auth.StdTx{}, decodedTx)