From 0a5400fd11ad0a078b2a089c168bdfb1d1b3123c Mon Sep 17 00:00:00 2001 From: Justin Tieri <37750742+jtieri@users.noreply.github.com> Date: Fri, 12 Jan 2024 15:31:49 -0600 Subject: [PATCH] test: debug timeouts on penumbra --- chain/penumbra/penumbra_client_node.go | 8 ++- examples/penumbra/penumbra_ibc_test.go | 70 +++++++++++++++++++++++--- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/chain/penumbra/penumbra_client_node.go b/chain/penumbra/penumbra_client_node.go index 15db25954..3e9bd0361 100644 --- a/chain/penumbra/penumbra_client_node.go +++ b/chain/penumbra/penumbra_client_node.go @@ -259,6 +259,9 @@ func (p *PenumbraClientNode) SendIBCTransfer( SourceChannel: channelID, } + fmt.Printf("Timeout: %+v \n", timeoutHeight) + fmt.Printf("Withdrawal: %+v \n", withdrawal) + // Generate a transaction plan sending ics_20 transfer tpr := &viewv1alpha1.TransactionPlannerRequest{ WalletId: nil, @@ -467,7 +470,10 @@ func (p *PenumbraClientNode) CreateNodeContainer(ctx context.Context) error { "start", } - return p.containerLifecycle.CreateContainer(ctx, p.TestName, p.NetworkID, p.Image, pclientdPorts, p.Bind(), nil, p.HostName(), cmd, nil) + // TODO: remove before merge + env := []string{"RUST_LOG=debug"} + + return p.containerLifecycle.CreateContainer(ctx, p.TestName, p.NetworkID, p.Image, pclientdPorts, p.Bind(), nil, p.HostName(), cmd, env) } // StopContainer stops the container associated with the PenumbraClientNode. diff --git a/examples/penumbra/penumbra_ibc_test.go b/examples/penumbra/penumbra_ibc_test.go index ecead8376..5ee09602e 100644 --- a/examples/penumbra/penumbra_ibc_test.go +++ b/examples/penumbra/penumbra_ibc_test.go @@ -60,8 +60,8 @@ func TestPenumbraToPenumbraIBC(t *testing.T) { chainB := chains[1].(*penumbra.PenumbraChain) i := ibc.DockerImage{ - Repository: "ghcr.io/cosmos/relayer", - Version: "main", + Repository: "relayer", + Version: "local", UidGid: "1025:1025", } r := interchaintest.NewBuiltinRelayerFactory( @@ -183,6 +183,35 @@ func TestPenumbraToPenumbraIBC(t *testing.T) { bobBal, err = chainB.GetBalance(ctx, bob.KeyName(), ibcDenom) require.NoError(t, err) require.True(t, bobBal.Equal(transferAmount), fmt.Sprintf("incorrect balance, got (%s) expected (%s)", bobBal, transferAmount)) + + transfer = ibc.WalletAmount{ + Address: bob.FormattedAddress(), + Denom: chainA.Config().Denom, + Amount: transferAmount, + } + + h, err = chainB.Height(ctx) + require.NoError(t, err) + + _, err = chainA.SendIBCTransfer(ctx, abChan.ChannelID, alice.KeyName(), transfer, ibc.TransferOptions{ + Timeout: &ibc.IBCTimeout{ + NanoSeconds: uint64((time.Duration(3) * time.Second).Nanoseconds()), + Height: h + 5, + }, + Memo: "", + }) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 7, chainA) + require.NoError(t, err) + + aliceBal, err = chainA.GetBalance(ctx, alice.KeyName(), chainA.Config().Denom) + require.NoError(t, err) + require.True(t, aliceBal.Equal(expectedBal), fmt.Sprintf("incorrect balance, got (%s) expected (%s)", aliceBal, initBalance)) + + bobBal, err = chainB.GetBalance(ctx, bob.FormattedAddress(), ibcDenom) + require.NoError(t, err) + require.True(t, bobBal.Equal(transferAmount), fmt.Sprintf("incorrect balance, got (%s) expected (%s)", bobBal, math.ZeroInt())) } // TestPenumbraToPenumbraIBC asserts that basic IBC functionality works between Penumbra and Cosmos testnet networks. @@ -196,7 +225,7 @@ func TestPenumbraToCosmosIBC(t *testing.T) { t.Parallel() client, network := interchaintest.DockerSetup(t) - nv := 2 + nv := 1 fn := 0 image := ibc.DockerImage{ @@ -243,8 +272,8 @@ func TestPenumbraToCosmosIBC(t *testing.T) { chainB := chains[1] i := ibc.DockerImage{ - Repository: "ghcr.io/cosmos/relayer", - Version: "main", + Repository: "relayer", + Version: "local", UidGid: "1025:1025", } r := interchaintest.NewBuiltinRelayerFactory( @@ -337,7 +366,7 @@ func TestPenumbraToCosmosIBC(t *testing.T) { abChan, err := ibc.GetTransferChannel(ctx, r, eRep, chainA.Config().ChainID, chainB.Config().ChainID) require.NoError(t, err) - h, err := chainA.Height(ctx) + h, err := chainB.Height(ctx) require.NoError(t, err) _, err = chainA.SendIBCTransfer(ctx, abChan.ChannelID, alice.KeyName(), transfer, ibc.TransferOptions{ @@ -388,4 +417,33 @@ func TestPenumbraToCosmosIBC(t *testing.T) { bobBal, err = chainB.GetBalance(ctx, bob.FormattedAddress(), chainADenomOnChainB) require.NoError(t, err) require.True(t, bobBal.Equal(math.ZeroInt()), fmt.Sprintf("incorrect balance, got (%s) expected (%s)", bobBal, math.ZeroInt())) + + transfer = ibc.WalletAmount{ + Address: bob.FormattedAddress(), + Denom: chainA.Config().Denom, + Amount: transferAmount, + } + + h, err = chainB.Height(ctx) + require.NoError(t, err) + + _, err = chainA.SendIBCTransfer(ctx, abChan.ChannelID, alice.KeyName(), transfer, ibc.TransferOptions{ + Timeout: &ibc.IBCTimeout{ + NanoSeconds: uint64((time.Duration(3) * time.Second).Nanoseconds()), + Height: h + 5, + }, + Memo: "", + }) + require.NoError(t, err) + + err = testutil.WaitForBlocks(ctx, 7, chainA) + require.NoError(t, err) + + aliceBal, err = chainA.GetBalance(ctx, alice.KeyName(), chainA.Config().Denom) + require.NoError(t, err) + require.True(t, initBalance.Equal(aliceBal), fmt.Sprintf("incorrect balance, got (%s) expected (%s)", aliceBal, initBalance)) + + bobBal, err = chainB.GetBalance(ctx, bob.FormattedAddress(), chainADenomOnChainB) + require.NoError(t, err) + require.True(t, bobBal.Equal(math.ZeroInt()), fmt.Sprintf("incorrect balance, got (%s) expected (%s)", bobBal, math.ZeroInt())) }