diff --git a/app/app_parallel_test.go b/app/app_parallel_test.go index f207579c90..c051d7f2a3 100644 --- a/app/app_parallel_test.go +++ b/app/app_parallel_test.go @@ -430,7 +430,7 @@ func TestParallelTxs(t *testing.T) { // ## only cosmos txs ## // ##################### { - "5 cosmos txs, 0 group: a->b b->c c->d d->e e->f", + "5 cosmos txs, 1 group: a->b b->c c->d d->e e->f", func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { var rawTxs [][]byte @@ -443,7 +443,22 @@ func TestParallelTxs(t *testing.T) { []uint32{0, 0, 0, 0, 0}, }, { - "4 cosmos txs, 1 Failed cosmos tx, 0 group: a->b failed(b->c) / d->e e->f f->g", + "4 cosmos txs, 1 Failed cosmos tx, 1 group: a->b failed(b->c) b->c c->d d->f", + func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { + + var rawTxs [][]byte + rawTxs = append(rawTxs, createTokenSendTx(t, chain, 0)) + rawTxs = append(rawTxs, createFailedTokenSendTx(t, chain, 1)) + for i := 2; i < 5; i++ { + rawTxs = append(rawTxs, createTokenSendTx(t, chain, i)) + } + ret := runTxs(chain, rawTxs, isParallel) + return ret, resultHash(ret), chain.app.BaseApp.LastCommitID().Hash + }, + []uint32{0, 61034, 0, 0, 0}, + }, + { + "4 cosmos txs, 1 Failed cosmos tx, 2 group: a->b failed(b->c) / d->e e->f f->g", func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { var rawTxs [][]byte @@ -458,7 +473,7 @@ func TestParallelTxs(t *testing.T) { []uint32{0, 61034, 0, 0, 0}, }, { - "4 cosmos txs, 1 AnteErr cosmos tx, 0 group: a->b AnteErr(b->c) c->d d->e e->f", + "4 cosmos txs, 1 AnteErr cosmos tx, 1 group: a->b AnteErr(b->c) c->d d->e e->f", func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { var rawTxs [][]byte @@ -473,7 +488,7 @@ func TestParallelTxs(t *testing.T) { []uint32{0, 5, 0, 0, 0}, }, { - "4 failed cosmos txs, 1 AnteErr cosmos tx, 0 group", + "4 failed cosmos txs, 1 AnteErr cosmos tx, 1 group", func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { var rawTxs [][]byte @@ -488,7 +503,7 @@ func TestParallelTxs(t *testing.T) { []uint32{61034, 5, 61034, 61034, 61034}, }, { - "3 cosmos txs, 1 failed cosmos tx, 1 AnteErr cosmos tx, 0 group: a->b b->c c->d d->e e->f", + "3 cosmos txs, 1 failed cosmos tx, 1 AnteErr cosmos tx, 1 group: a->b b->c c->d d->e e->f", func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { var rawTxs [][]byte @@ -504,7 +519,7 @@ func TestParallelTxs(t *testing.T) { []uint32{0, 61034, 5, 0, 0}, }, { - "5 failed cosmos txs, 0 group: a->b b->c c->d d->e e->f", + "5 failed cosmos txs, 1 group: a->b b->c c->d d->e e->f", func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { var rawTxs [][]byte @@ -516,6 +531,69 @@ func TestParallelTxs(t *testing.T) { }, []uint32{61034, 61034, 61034, 61034, 61034}, }, + { + "5 cosmos txs, 2 group: a->b b->c / d->e e->f f->g", + func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { + + var rawTxs [][]byte + for i := 0; i < 2; i++ { + rawTxs = append(rawTxs, createTokenSendTx(t, chain, i)) + } + for i := 3; i < 6; i++ { + rawTxs = append(rawTxs, createTokenSendTx(t, chain, i)) + } + ret := runTxs(chain, rawTxs, isParallel) + return ret, resultHash(ret), chain.app.BaseApp.LastCommitID().Hash + }, + []uint32{0, 0, 0, 0, 0}, + }, + { + "4 cosmos txs, 1 AnteErr cosmos tx, 2 group: a->b AnteErr(b->c) / d->e e->f f->g", + func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { + + var rawTxs [][]byte + rawTxs = append(rawTxs, createTokenSendTx(t, chain, 0)) + rawTxs = append(rawTxs, createAnteErrTokenSendTx(t, chain, 1)) + for i := 3; i < 6; i++ { + rawTxs = append(rawTxs, createTokenSendTx(t, chain, i)) + } + ret := runTxs(chain, rawTxs, isParallel) + return ret, resultHash(ret), chain.app.BaseApp.LastCommitID().Hash + }, + []uint32{0, 5, 0, 0, 0}, + }, + { + "3 cosmos txs, 1 failed cosmos tx, 1 AnteErr cosmos tx, 2 group: a->b failed(b->c) / AnteErr(d->e) e->f f->g", + func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { + + var rawTxs [][]byte + rawTxs = append(rawTxs, createTokenSendTx(t, chain, 0)) + rawTxs = append(rawTxs, createFailedTokenSendTx(t, chain, 1)) + rawTxs = append(rawTxs, createAnteErrTokenSendTx(t, chain, 3)) + for i := 4; i < 6; i++ { + rawTxs = append(rawTxs, createTokenSendTx(t, chain, i)) + } + ret := runTxs(chain, rawTxs, isParallel) + return ret, resultHash(ret), chain.app.BaseApp.LastCommitID().Hash + }, + []uint32{0, 61034, 5, 0, 0}, + }, + { + "3 cosmos txs, 1 failed cosmos tx, 1 AnteErr cosmos tx, 2 group: a->b failed(b->c) AnteErr(d->e) / e->f f->g", + func(t *testing.T, chain *Chain, isParallel bool) ([]*abci.ResponseDeliverTx, []byte, []byte) { + + var rawTxs [][]byte + rawTxs = append(rawTxs, createTokenSendTx(t, chain, 0)) + rawTxs = append(rawTxs, createFailedTokenSendTx(t, chain, 1)) + rawTxs = append(rawTxs, createAnteErrTokenSendTx(t, chain, 2)) + for i := 4; i < 6; i++ { + rawTxs = append(rawTxs, createTokenSendTx(t, chain, i)) + } + ret := runTxs(chain, rawTxs, isParallel) + return ret, resultHash(ret), chain.app.BaseApp.LastCommitID().Hash + }, + []uint32{0, 61034, 5, 0, 0}, + }, // ##################### // ###### mix txs ###### // ##################### diff --git a/x/token/types/msgs.go b/x/token/types/msgs.go index 14fc41bbfb..60f9b04203 100644 --- a/x/token/types/msgs.go +++ b/x/token/types/msgs.go @@ -2,6 +2,10 @@ package types import ( + "strings" + + ethcmm "github.com/ethereum/go-ethereum/common" + sdk "github.com/okex/exchain/libs/cosmos-sdk/types" "github.com/okex/exchain/x/common" ) @@ -14,7 +18,6 @@ const ( TotalSupplyUpperbound = int64(9 * 1e10) ) -// type MsgTokenIssue struct { Description string `json:"description"` Symbol string `json:"symbol"` @@ -252,6 +255,10 @@ func (msg MsgSend) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{msg.FromAddress} } +func (msg MsgSend) CalFromAndToForPara() (string, string) { + return strings.ToLower(ethcmm.BytesToAddress(msg.FromAddress).String()[2:]), strings.ToLower(ethcmm.BytesToAddress(msg.ToAddress).String()[2:]) +} + // MsgTransferOwnership - high level transaction of the coin module type MsgTransferOwnership struct { FromAddress sdk.AccAddress `json:"from_address"`