Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed May 7, 2024
1 parent 9bd13ca commit 0cdd673
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 32 deletions.
3 changes: 3 additions & 0 deletions chain/cosmos/cosmos_chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,9 @@ func (c *CosmosChain) StartConsumer(testName string, ctx context.Context, additi
consumerICS := c.GetNode().ICSVersion(ctx)
providerICS := c.Provider.GetNode().ICSVersion(ctx)
ccvStateMarshaled, err = c.transformCCVState(ctx, ccvStateMarshaled, consumerICS, providerICS, chainCfg.InterchainSecurityConfig)
if err != nil {
return fmt.Errorf("failed to transform ccv state: %w", err)
}

c.log.Info("HERE STATE!", zap.String("GEN", string(ccvStateMarshaled)))
if err != nil {
Expand Down
59 changes: 27 additions & 32 deletions examples/ibc/ics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testreporter"
"github.com/strangelove-ventures/interchaintest/v8/testutil"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
)
Expand Down Expand Up @@ -97,45 +96,41 @@ func TestICS(t *testing.T) {
valOne := stakingVals[0]
denom := provider.Config().Denom

// delegate from the "validator" key
err = provider.GetNode().StakingDelegate(ctx, "validator", valOne.OperatorAddress, fmt.Sprintf("100%s", denom))
require.NoError(t, err, "failed to delegate from validator")
// Perform validator delegation
// The delegation must be >1,000,000 utoken as this is = 1 power in tendermint.
t.Run("perform provider delegation to complete channel to the consumer", func(t *testing.T) {
beforeDel, err := provider.StakingQueryDelegationsTo(ctx, valOne.OperatorAddress)
require.NoError(t, err)

err = provider.GetNode().StakingDelegate(ctx, "validator", valOne.OperatorAddress, fmt.Sprintf("1000000%s", denom))
require.NoError(t, err, "failed to delegate from validator")

// now wait for the relayer event to be processes
afterDel, err := provider.StakingQueryDelegationsTo(ctx, valOne.OperatorAddress)
require.NoError(t, err)
require.Greater(t, afterDel[0].Balance.Amount.Int64(), beforeDel[0].Balance.Amount.Int64())
})

// relayer flush
// Flush pending ICS packet
channels, err := r.GetChannels(ctx, eRep, providerChainID)
require.NoError(t, err)
// require.Len(t, channels, 2)

// get the ics20-1 transfer channel
var transferChannel = ""
var ICSChannel = ""
for _, channel := range channels {
fmt.Printf("channel: %v\n", channel)
// TODO: this is stuck in TRYOPEN state? channel: {STATE_TRYOPEN ORDER_UNORDERED {transfer channel-1} [connection-0] ics20-1 transfer channel-1}
if channel.Version == "ics20-1" {
transferChannel = channel.ChannelID
if channel.PortID == "provider" {
ICSChannel = channel.ChannelID
}
}
require.NotEmpty(t, transferChannel)

require.NoError(t, r.Flush(ctx, eRep, ibcPath, transferChannel))
require.NoError(t, r.Flush(ctx, eRep, ibcPath, ICSChannel))

err = testutil.WaitForBlocks(ctx, 15, provider, consumer)
require.NoError(t, err, "failed to wait for blocks")
t.Run("validate consumer actions now execute", func(t *testing.T) {
t.Parallel()
amt := math.NewInt(1_000_000)
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", amt, consumer)

// perform an action on the consumer
users := interchaintest.GetAndFundTestUsers(t, ctx, "default", math.NewInt(10_000_000), consumer)
fmt.Printf("users: %v\n", users)
// get balance & print
for _, user := range users {
bal, err := consumer.BankQueryBalance(ctx, user.FormattedAddress(), consumer.Config().Denom)
require.NoError(t, err)
fmt.Printf("user: %v, balance: %v\n", user.FormattedAddress(), bal)
}

err = testutil.WaitForBlocks(ctx, 1000, provider, consumer)
require.NoError(t, err, "failed to wait for blocks")

// perform ibc transfer here from provider -> consumer
for _, user := range users {
bal, err := consumer.BankQueryBalance(ctx, user.FormattedAddress(), consumer.Config().Denom)
require.NoError(t, err)
require.EqualValues(t, amt, bal)
}
})
}

0 comments on commit 0cdd673

Please sign in to comment.