Skip to content

Commit

Permalink
remove numbered messages
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Jun 19, 2024
1 parent 1d80064 commit 001bdfa
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 144 deletions.
6 changes: 3 additions & 3 deletions x/crosschain/keeper/msg_server_vote_inbound_tx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func TestKeeper_VoteInbound(t *testing.T) {
require.True(t, found)
require.Equal(t, ballot.BallotStatus, observertypes.BallotStatus_BallotFinalized_SuccessObservation)
//Perform the SAME event. Except, this time, we resubmit the event.
msg2 := &types.MsgVoteInbound{
msg = &types.MsgVoteInbound{
Creator: validatorAddr,
Sender: "0x954598965C2aCdA2885B037561526260764095B8",
SenderChainId: 1337,
Expand All @@ -159,11 +159,11 @@ func TestKeeper_VoteInbound(t *testing.T) {

_, err = msgServer.VoteInbound(
ctx,
msg2,
msg,
)
require.Error(t, err)
require.ErrorIs(t, err, types.ErrObservedTxAlreadyFinalized)
_, found = zk.ObserverKeeper.GetBallot(ctx, msg2.Digest())
_, found = zk.ObserverKeeper.GetBallot(ctx, msg.Digest())
require.False(t, found)
})

Expand Down
84 changes: 42 additions & 42 deletions x/crosschain/types/message_vote_inbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,87 +158,87 @@ func TestMsgVoteInbound_Digest(t *testing.T) {
require.NotEmpty(t, hash, "hash should not be empty")

// creator not used
msg2 := msg
msg2.Creator = sample.AccAddress()
hash2 := msg2.Digest()
msg = msg
msg.Creator = sample.AccAddress()
hash2 := msg.Digest()
require.Equal(t, hash, hash2, "creator should not change hash")

// in block height not used
msg2 = msg
msg2.InboundBlockHeight = 43
hash2 = msg2.Digest()
msg = msg
msg.InboundBlockHeight = 43
hash2 = msg.Digest()
require.Equal(t, hash, hash2, "in block height should not change hash")

// sender used
msg2 = msg
msg2.Sender = sample.AccAddress()
hash2 = msg2.Digest()
msg = msg
msg.Sender = sample.AccAddress()
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "sender should change hash")

// sender chain ID used
msg2 = msg
msg2.SenderChainId = 43
hash2 = msg2.Digest()
msg = msg
msg.SenderChainId = 43
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "sender chain ID should change hash")

// tx origin used
msg2 = msg
msg2.TxOrigin = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msg = msg
msg.TxOrigin = sample.StringRandom(r, 32)
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "tx origin should change hash")

// receiver used
msg2 = msg
msg2.Receiver = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msg = msg
msg.Receiver = sample.StringRandom(r, 32)
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "receiver should change hash")

// receiver chain ID used
msg2 = msg
msg2.ReceiverChain = 43
hash2 = msg2.Digest()
msg = msg
msg.ReceiverChain = 43
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "receiver chain ID should change hash")

// amount used
msg2 = msg
msg2.Amount = math.NewUint(43)
hash2 = msg2.Digest()
msg = msg
msg.Amount = math.NewUint(43)
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "amount should change hash")

// message used
msg2 = msg
msg2.Message = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msg = msg
msg.Message = sample.StringRandom(r, 32)
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "message should change hash")

// in tx hash used
msg2 = msg
msg2.InboundHash = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msg = msg
msg.InboundHash = sample.StringRandom(r, 32)
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "in tx hash should change hash")

// gas limit used
msg2 = msg
msg2.GasLimit = 43
hash2 = msg2.Digest()
msg = msg
msg.GasLimit = 43
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "gas limit should change hash")

// coin type used
msg2 = msg
msg2.CoinType = coin.CoinType_ERC20
hash2 = msg2.Digest()
msg = msg
msg.CoinType = coin.CoinType_ERC20
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "coin type should change hash")

// asset used
msg2 = msg
msg2.Asset = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msg = msg
msg.Asset = sample.StringRandom(r, 32)
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "asset should change hash")

// event index used
msg2 = msg
msg2.EventIndex = 43
hash2 = msg2.Digest()
msg = msg
msg.EventIndex = 43
hash2 = msg.Digest()
require.NotEqual(t, hash, hash2, "event index should change hash")
}

Expand Down
72 changes: 36 additions & 36 deletions x/crosschain/types/message_vote_outbound_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,75 +109,75 @@ func TestMsgVoteOutbound_Digest(t *testing.T) {
require.NotEmpty(t, hash, "hash should not be empty")

// creator not used
msg2 := msg
msg2.Creator = sample.AccAddress()
hash2 := msg2.Digest()
msgNew := msg
msgNew.Creator = sample.AccAddress()
hash2 := msgNew.Digest()
require.Equal(t, hash, hash2, "creator should not change hash")

// status not used
msg2 = msg
msg2.Status = chains.ReceiveStatus_failed
hash2 = msg2.Digest()
msgNew = msg
msgNew.Status = chains.ReceiveStatus_failed
hash2 = msgNew.Digest()
require.Equal(t, hash, hash2, "status should not change hash")

// cctx hash used
msg2 = msg
msg2.CctxHash = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msgNew = msg
msgNew.CctxHash = sample.StringRandom(r, 32)
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "cctx hash should change hash")

// observed outbound tx hash used
msg2 = msg
msg2.ObservedOutboundHash = sample.StringRandom(r, 32)
hash2 = msg2.Digest()
msgNew = msg
msgNew.ObservedOutboundHash = sample.StringRandom(r, 32)
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "observed outbound tx hash should change hash")

// observed outbound tx block height used
msg2 = msg
msg2.ObservedOutboundBlockHeight = 43
hash2 = msg2.Digest()
msgNew = msg
msgNew.ObservedOutboundBlockHeight = 43
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "observed outbound tx block height should change hash")

// observed outbound tx gas used used
msg2 = msg
msg2.ObservedOutboundGasUsed = 43
hash2 = msg2.Digest()
msgNew = msg
msgNew.ObservedOutboundGasUsed = 43
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "observed outbound tx gas used should change hash")

// observed outbound tx effective gas price used
msg2 = msg
msg2.ObservedOutboundEffectiveGasPrice = math.NewInt(43)
hash2 = msg2.Digest()
msgNew = msg
msgNew.ObservedOutboundEffectiveGasPrice = math.NewInt(43)
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "observed outbound tx effective gas price should change hash")

// observed outbound tx effective gas limit used
msg2 = msg
msg2.ObservedOutboundEffectiveGasLimit = 43
hash2 = msg2.Digest()
msgNew = msg
msgNew.ObservedOutboundEffectiveGasLimit = 43
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "observed outbound tx effective gas limit should change hash")

// zeta minted used
msg2 = msg
msg2.ValueReceived = math.NewUint(43)
hash2 = msg2.Digest()
msgNew = msg
msgNew.ValueReceived = math.NewUint(43)
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "zeta minted should change hash")

// out tx chain used
msg2 = msg
msg2.OutboundChain = 43
hash2 = msg2.Digest()
msgNew = msg
msgNew.OutboundChain = 43
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "out tx chain should change hash")

// out tx tss nonce used
msg2 = msg
msg2.OutboundTssNonce = 43
hash2 = msg2.Digest()
msgNew = msg
msgNew.OutboundTssNonce = 43
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "out tx tss nonce should change hash")

// coin type used
msg2 = msg
msg2.CoinType = coin.CoinType_ERC20
hash2 = msg2.Digest()
msgNew = msg
msgNew.CoinType = coin.CoinType_ERC20
hash2 = msgNew.Digest()
require.NotEqual(t, hash, hash2, "coin type should change hash")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) {
require.Equal(t, gasAddress, gas.Hex())

// can deploy non-gas zrc20
msg2 := types.NewMsgDeployFungibleCoinZRC20(
msg = types.NewMsgDeployFungibleCoinZRC20(
admin,
sample.EthAddress().Hex(),
chainID,
Expand All @@ -73,8 +73,8 @@ func TestMsgServer_DeployFungibleCoinZRC20(t *testing.T) {
coin.CoinType_ERC20,
2000000,
)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg2, nil)
res, err = msgServer.DeployFungibleCoinZRC20(ctx, msg2)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg, nil)
res, err = msgServer.DeployFungibleCoinZRC20(ctx, msg)
require.NoError(t, err)

assertContractDeployment(t, sdkk.EvmKeeper, ctx, ethcommon.HexToAddress(res.Address))
Expand Down
12 changes: 6 additions & 6 deletions x/fungible/keeper/msg_server_pause_zrc20_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,30 +63,30 @@ func TestKeeper_PauseZRC20(t *testing.T) {
assertUnpaused(zrc20C)

// can pause already paused zrc20
msg2 := types.NewMsgPauseZRC20(
msg = types.NewMsgPauseZRC20(
admin,
[]string{
zrc20B,
},
)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg2, nil)
_, err = msgServer.PauseZRC20(ctx, msg2)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg, nil)
_, err = msgServer.PauseZRC20(ctx, msg)
require.NoError(t, err)
assertPaused(zrc20A)
assertPaused(zrc20B)
assertUnpaused(zrc20C)

// can pause all zrc20
msg3 := types.NewMsgPauseZRC20(
msg = types.NewMsgPauseZRC20(
admin,
[]string{
zrc20A,
zrc20B,
zrc20C,
},
)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg3, nil)
_, err = msgServer.PauseZRC20(ctx, msg3)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg, nil)
_, err = msgServer.PauseZRC20(ctx, msg)
require.NoError(t, err)
assertPaused(zrc20A)
assertPaused(zrc20B)
Expand Down
18 changes: 9 additions & 9 deletions x/fungible/keeper/msg_server_udpate_zrc20_liquidity_cap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) {
require.True(t, coin.LiquidityCap.Equal(math.NewUint(42)), "invalid liquidity cap", coin.LiquidityCap.String())

// can update liquidity cap again
msg2 := types.NewMsgUpdateZRC20LiquidityCap(
msg = types.NewMsgUpdateZRC20LiquidityCap(
admin,
coinAddress,
math.NewUint(4200000),
)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg2, nil)
_, err = msgServer.UpdateZRC20LiquidityCap(ctx, msg2)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg, nil)
_, err = msgServer.UpdateZRC20LiquidityCap(ctx, msg)
require.NoError(t, err)

coin, found = k.GetForeignCoins(ctx, coinAddress)
Expand All @@ -63,27 +63,27 @@ func TestMsgServer_UpdateZRC20LiquidityCap(t *testing.T) {
)

// can set liquidity cap to 0
msg3 := types.NewMsgUpdateZRC20LiquidityCap(
msg = types.NewMsgUpdateZRC20LiquidityCap(
admin,
coinAddress,
math.NewUint(0),
)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg3, nil)
_, err = msgServer.UpdateZRC20LiquidityCap(ctx, msg3)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg, nil)
_, err = msgServer.UpdateZRC20LiquidityCap(ctx, msg)
require.NoError(t, err)

coin, found = k.GetForeignCoins(ctx, coinAddress)
require.True(t, found)
require.True(t, coin.LiquidityCap.Equal(math.ZeroUint()), "invalid liquidity cap", coin.LiquidityCap.String())

// can set liquidity cap to nil
msg4 := types.NewMsgUpdateZRC20LiquidityCap(
msg = types.NewMsgUpdateZRC20LiquidityCap(
admin,
coinAddress,
math.Uint{},
)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg4, nil)
_, err = msgServer.UpdateZRC20LiquidityCap(ctx, msg4)
keepertest.MockCheckAuthorization(&authorityMock.Mock, msg, nil)
_, err = msgServer.UpdateZRC20LiquidityCap(ctx, msg)
require.NoError(t, err)

coin, found = k.GetForeignCoins(ctx, coinAddress)
Expand Down
Loading

0 comments on commit 001bdfa

Please sign in to comment.