Skip to content

Commit

Permalink
add protocol v2
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Dec 13, 2024
1 parent 2be31f2 commit c6c8000
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions pkg/memo/memo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/node/pkg/memo"
"github.com/zeta-chain/node/testutil/sample"
crosschaintypes "github.com/zeta-chain/node/x/crosschain/types"
)

Expand Down Expand Up @@ -324,6 +325,7 @@ func Test_DecodeLegacyMemoHex(t *testing.T) {
{"empty msg", "", common.Address{}, nil, false},
{"invalid hex", "invalidHex", common.Address{}, nil, true},
{"short msg", "1a2b3c4d5e6f708192a3b4c5d6e7f808", common.Address{}, expectedShortMsgResult, false},
{"random message", sample.EthAddress().String(), common.Address{}, nil, true},
}

for _, tt := range tests {
Expand Down
24 changes: 16 additions & 8 deletions testutil/sample/crosschain.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,19 +370,26 @@ func InboundVoteFromRand(from, to int64, r *rand.Rand, asset string) types.MsgVo
Receiver: EthAddressFromRand(r).String(),
ReceiverChain: to,
Amount: math.NewUint(r.Uint64()),
Message: "95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5",
Message: EthAddressFromRand(r).String(),
InboundBlockHeight: r.Uint64(),
CallOptions: &types.CallOptions{
GasLimit: 1000000000,
},
InboundHash: ethcommon.BytesToHash(RandomBytes(r)).String(),
CoinType: coinType,
TxOrigin: EthAddressFromRand(r).String(),
Asset: asset,
EventIndex: r.Uint64(),
InboundHash: ethcommon.BytesToHash(RandomBytes(r)).String(),
CoinType: coinType,
TxOrigin: EthAddressFromRand(r).String(),
Asset: asset,
EventIndex: r.Uint64(),
ProtocolContractVersion: ProtocolVersionFromRand(r),
}
}

func ProtocolVersionFromRand(r *rand.Rand) types.ProtocolContractVersion {
versions := []types.ProtocolContractVersion{types.ProtocolContractVersion_V1, types.ProtocolContractVersion_V2}
return versions[r.Intn(len(versions))]

}

Check failure on line 391 in testutil/sample/crosschain.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary trailing newline (whitespace)

func CoinTypeFromRand(r *rand.Rand) coin.CoinType {
coinTypes := []coin.CoinType{coin.CoinType_Gas, coin.CoinType_ERC20, coin.CoinType_Zeta}
coinType := coinTypes[r.Intn(len(coinTypes))]
Expand Down Expand Up @@ -441,8 +448,9 @@ func CCTXfromRand(r *rand.Rand,
IsAbortRefunded: false,
Status: types.CctxStatus_PendingOutbound,
},
InboundParams: inbound,
OutboundParams: []*types.OutboundParams{outbound},
InboundParams: inbound,
OutboundParams: []*types.OutboundParams{outbound},
ProtocolContractVersion: ProtocolVersionFromRand(r),
}
return cctx
}
Expand Down

0 comments on commit c6c8000

Please sign in to comment.