Skip to content

Commit

Permalink
fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
gjermundgaraba committed Nov 19, 2024
1 parent 152b783 commit 0f25a3a
Show file tree
Hide file tree
Showing 22 changed files with 501 additions and 132 deletions.
100 changes: 100 additions & 0 deletions abi/ICS20Transfer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,106 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "createMsgSendPacket",
"inputs": [
{
"name": "msg_",
"type": "tuple",
"internalType": "struct IICS20TransferMsgs.SendTransferMsg",
"components": [
{
"name": "denom",
"type": "string",
"internalType": "string"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "receiver",
"type": "string",
"internalType": "string"
},
{
"name": "sourceChannel",
"type": "string",
"internalType": "string"
},
{
"name": "destPort",
"type": "string",
"internalType": "string"
},
{
"name": "timeoutTimestamp",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "memo",
"type": "string",
"internalType": "string"
}
]
}
],
"outputs": [
{
"name": "",
"type": "tuple",
"internalType": "struct IICS26RouterMsgs.MsgSendPacket",
"components": [
{
"name": "sourceChannel",
"type": "string",
"internalType": "string"
},
{
"name": "timeoutTimestamp",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "payloads",
"type": "tuple[]",
"internalType": "struct IICS26RouterMsgs.Payload[]",
"components": [
{
"name": "sourcePort",
"type": "string",
"internalType": "string"
},
{
"name": "destPort",
"type": "string",
"internalType": "string"
},
{
"name": "version",
"type": "string",
"internalType": "string"
},
{
"name": "encoding",
"type": "string",
"internalType": "string"
},
{
"name": "value",
"type": "bytes",
"internalType": "bytes"
}
]
}
]
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "escrow",
Expand Down
11 changes: 6 additions & 5 deletions abi/ICS26Router.json
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,12 @@
],
"anonymous": false
},
{
"type": "event",
"name": "Noop",
"inputs": [],
"anonymous": false
},
{
"type": "event",
"name": "OwnershipTransferred",
Expand Down Expand Up @@ -946,11 +952,6 @@
"name": "IBCMultiPayloadPacketNotSupported",
"inputs": []
},
{
"type": "error",
"name": "IBCMultiPayloadPacketNotSupported",
"inputs": []
},
{
"type": "error",
"name": "IBCPacketCommitmentMismatch",
Expand Down
7 changes: 7 additions & 0 deletions e2e/interchaintestv8/e2esuite/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ func (s *TestSuite) GetTransactOpts(key *ecdsa.PrivateKey) *bind.TransactOpts {
return txOpts
}

func (s *TestSuite) GetCallOpts(key *ecdsa.PrivateKey) *bind.CallOpts {
return &bind.CallOpts{
From: bind.NewKeyedTransactor(key).From,
Context: context.Background(),
}
}

// PushNewWasmClientProposal submits a new wasm client governance proposal to the chain.
func (s *TestSuite) PushNewWasmClientProposal(ctx context.Context, chain *cosmos.CosmosChain, wallet ibc.Wallet, proposalContentReader io.Reader) string {
zippedContent, err := io.ReadAll(proposalContentReader)
Expand Down
99 changes: 66 additions & 33 deletions e2e/interchaintestv8/ibc_eureka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,6 @@ func (s *IbcEurekaTestSuite) ICS20TransferERC20TokenfromEthereumToCosmosAndBackT

ics26routerAbi, err := abi.JSON(strings.NewReader(ics26router.ContractABI))
s.Require().NoError(err)
ics20transferAbi, err := abi.JSON(strings.NewReader(ics20transfer.ContractABI))
s.Require().NoError(err)

s.Require().True(s.Run("Approve the ICS20Transfer.sol contract to spend the erc20 tokens", func() {
tx, err := s.erc20Contract.Approve(s.GetTransactOpts(s.key), ics20Address, totalTransferAmount)
Expand All @@ -355,22 +353,23 @@ func (s *IbcEurekaTestSuite) ICS20TransferERC20TokenfromEthereumToCosmosAndBackT
s.Require().True(s.Run(fmt.Sprintf("Send %d transfers on Ethereum", numOfTransfers), func() {
timeout := uint64(time.Now().Add(30 * time.Minute).Unix())
transferMulticall := make([][]byte, numOfTransfers)
msgSendTransfer := ics20transfer.IICS20TransferMsgsSendTransferMsg{
Denom: s.contractAddresses.Erc20,
Amount: transferAmount,
Receiver: cosmosUserAddress,
SourceChannel: s.TendermintLightClientID,
DestPort: transfertypes.PortID,
TimeoutTimestamp: timeout,
Memo: "",
}
encodedMsg, err := ics20transferAbi.Pack("sendTransfer", msgSendTransfer)

msgSendPacket := s.createICS20MsgSendPacket(
s.contractAddresses.Erc20,
transferAmount,
cosmosUserAddress,
s.TendermintLightClientID,
timeout,
"",
)

encodedMsg, err := ics26routerAbi.Pack("sendPacket", msgSendPacket)
s.Require().NoError(err)
for i := 0; i < numOfTransfers; i++ {
transferMulticall[i] = encodedMsg
}

tx, err := s.ics20Contract.Multicall(s.GetTransactOpts(s.key), transferMulticall)
tx, err := s.ics26Contract.Multicall(s.GetTransactOpts(s.key), transferMulticall)
s.Require().NoError(err)
receipt := s.GetTxReciept(ctx, eth, tx.Hash())
s.Require().Equal(ethtypes.ReceiptStatusSuccessful, receipt.Status)
Expand Down Expand Up @@ -944,17 +943,16 @@ func (s *IbcEurekaTestSuite) ICS20TransferNativeCosmosCoinsToEthereumAndBackTest
var sendBlockNumber int64
s.Require().True(s.Run("Transfer tokens back from Ethereum", func() {
timeout := uint64(time.Now().Add(30 * time.Minute).Unix())
msgSendTransfer := ics20transfer.IICS20TransferMsgsSendTransferMsg{
Denom: ibcERC20Address,
Amount: transferAmount,
Receiver: cosmosUserAddress,
SourceChannel: s.TendermintLightClientID,
DestPort: transfertypes.PortID,
TimeoutTimestamp: timeout,
Memo: returnMemo,
}
msgSendPacket := s.createICS20MsgSendPacket(
ibcERC20Address,
transferAmount,
cosmosUserAddress,
s.TendermintLightClientID,
timeout,
returnMemo,
)

tx, err := s.ics20Contract.SendTransfer(s.GetTransactOpts(s.key), msgSendTransfer)
tx, err := s.ics26Contract.SendPacket(s.GetTransactOpts(s.key), msgSendPacket)
s.Require().NoError(err)
receipt := s.GetTxReciept(ctx, eth, tx.Hash())
s.Require().Equal(ethtypes.ReceiptStatusSuccessful, receipt.Status)
Expand Down Expand Up @@ -1104,17 +1102,17 @@ func (s *IbcEurekaTestSuite) ICS20TransferTimeoutFromEthereumToCosmosChainTest(c
var timeout uint64
s.Require().True(s.Run("Send transfer on Ethereum", func() {
timeout = uint64(time.Now().Add(30 * time.Second).Unix())
msgSendTransfer := ics20transfer.IICS20TransferMsgsSendTransferMsg{
Denom: s.contractAddresses.Erc20,
Amount: transferAmount,
Receiver: cosmosUserAddress,
SourceChannel: s.TendermintLightClientID,
DestPort: "transfer",
TimeoutTimestamp: timeout,
Memo: "testmemo",
}

tx, err := s.ics20Contract.SendTransfer(s.GetTransactOpts(s.key), msgSendTransfer)
msgSendPacket := s.createICS20MsgSendPacket(
s.contractAddresses.Erc20,
transferAmount,
cosmosUserAddress,
s.TendermintLightClientID,
timeout,
"testmemo",
)

tx, err := s.ics26Contract.SendPacket(s.GetTransactOpts(s.key), msgSendPacket)
s.Require().NoError(err)
receipt := s.GetTxReciept(ctx, eth, tx.Hash())
s.Require().Equal(ethtypes.ReceiptStatusSuccessful, receipt.Status)
Expand Down Expand Up @@ -1189,6 +1187,41 @@ func (s *IbcEurekaTestSuite) ICS20TransferTimeoutFromEthereumToCosmosChainTest(c
}))
}

func (s *IbcEurekaTestSuite) createICS20MsgSendPacket(
denom string,
amount *big.Int,
receiver string,
sourceChannel string,
timeoutTimestamp uint64,
memo string,
) ics26router.IICS26RouterMsgsMsgSendPacket {
msgSendTransfer := ics20transfer.IICS20TransferMsgsSendTransferMsg{
Denom: denom,
Amount: amount,
Receiver: receiver,
SourceChannel: sourceChannel,
DestPort: transfertypes.PortID,
TimeoutTimestamp: timeoutTimestamp,
Memo: memo,
}
msgSendPacket, err := s.ics20Contract.CreateMsgSendPacket(s.GetCallOpts(s.key), msgSendTransfer)
s.Require().NoError(err)

return ics26router.IICS26RouterMsgsMsgSendPacket{
SourceChannel: sourceChannel,
TimeoutTimestamp: timeoutTimestamp,
Payloads: []ics26router.IICS26RouterMsgsPayload{
{
SourcePort: msgSendPacket.Payloads[0].SourcePort,
DestPort: msgSendPacket.Payloads[0].DestPort,
Version: msgSendPacket.Payloads[0].Version,
Encoding: msgSendPacket.Payloads[0].Encoding,
Value: msgSendPacket.Payloads[0].Value,
},
},
}
}

func (s *IbcEurekaTestSuite) getCommitmentProof(path []byte) []byte {
eth, simd := s.ChainA, s.ChainB

Expand Down
Loading

0 comments on commit 0f25a3a

Please sign in to comment.