forked from cerc-io/laconicd-deprecated
Update ante handler unit tests
This commit is contained in:
+1
-20
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user