Skip to content

Commit

Permalink
test: debug timeouts on penumbra
Browse files Browse the repository at this point in the history
  • Loading branch information
jtieri committed Jan 12, 2024
1 parent 433936b commit 0a5400f
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
8 changes: 7 additions & 1 deletion chain/penumbra/penumbra_client_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down
70 changes: 64 additions & 6 deletions examples/penumbra/penumbra_ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand All @@ -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{
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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()))
}

0 comments on commit 0a5400f

Please sign in to comment.