Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Sep 8, 2024
1 parent 4f4e6a3 commit 13ccb90
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ test-e2e-cache:
go test -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e

test-e2e-cache-bcd-consumer-integration:
go test -run BCDConsumerIntegrationTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e
go test -run TestBCDConsumerIntegrationTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e

test-e2e-cache-ibc-transfer:
go test -run TestIBCTranferTestSuite -mod=readonly -timeout=60m -v $(PACKAGES_E2E) --tags=e2e
Expand Down
4 changes: 2 additions & 2 deletions client/query/btcstkconsumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (c *QueryClient) QueryConsumerRegistryList(pagination *sdkquerytypes.PageRe
}

// QueryConsumersRegistry returns the consumer systems with the given consumer IDs
func (c *QueryClient) QueryConsumersRegistry(consumerIDs []string) ([]*bsctypes.ConsumerRegister, error) {
func (c *QueryClient) QueryConsumersRegistry(consumerIDs []string) (*bsctypes.QueryConsumersRegistryResponse, error) {
var resp *bsctypes.QueryConsumersRegistryResponse
err := c.QueryBTCStkConsumer(func(ctx context.Context, queryClient bsctypes.QueryClient) error {
var err error
Expand All @@ -46,7 +46,7 @@ func (c *QueryClient) QueryConsumersRegistry(consumerIDs []string) ([]*bsctypes.
return err
})

return resp.ConsumersRegister, err
return resp, err
}

// QueryConsumerFinalityProviders returns a list of finality providers under the given consumer system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (bc *BabylonController) IBCChannels() (*channeltypes.QueryChannelsResponse,
return bc.bbnClient.IBCChannels()
}

func (bc *BabylonController) QueryConsumerRegistry(consumerID string) ([]*bsctypes.ConsumerRegister, error) {
func (bc *BabylonController) QueryConsumerRegistry(consumerID string) (*bsctypes.QueryConsumersRegistryResponse, error) {
return bc.bbnClient.QueryConsumersRegistry([]string{consumerID})
}

Expand Down
33 changes: 17 additions & 16 deletions test/e2e/bcd_consumer_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ func (s *BCDConsumerIntegrationTestSuite) TearDownSuite() {
}

// Construct the path to the Makefile directory
makefileDir := filepath.Join(currentDir, "bcd_integration")
makefileDir := filepath.Join(currentDir, "../../contrib/images")

// Run the stop-integration-test make target
cmd := exec.Command("make", "-C", makefileDir, "stop-integration-test")
cmd := exec.Command("make", "-C", makefileDir, "stop-bcd-consumer-integration")
output, err := cmd.CombinedOutput()
if err != nil {
s.T().Errorf("Failed to run stop-integration-test: %v\nOutput: %s", err, output)
Expand All @@ -89,16 +89,19 @@ func (s *BCDConsumerIntegrationTestSuite) Test1ChainStartup() {
// Use Babylon controller
s.Eventually(func() bool {
babylonStatus, err = s.babylonController.QueryNodeStatus()
return err == nil && babylonStatus.SyncInfo.LatestBlockHeight >= 1
return err == nil && babylonStatus != nil && babylonStatus.SyncInfo.LatestBlockHeight >= 1
}, time.Minute, time.Second, "Failed to query Babylon node status", err)
s.T().Logf("Babylon node status: %v", babylonStatus.SyncInfo.LatestBlockHeight)

// Use Cosmwasm controller
s.Eventually(func() bool {
consumerStatus, err = s.cosmwasmController.GetCometNodeStatus()
return err == nil && consumerStatus.SyncInfo.LatestBlockHeight >= 1
return err == nil && consumerStatus != nil && consumerStatus.SyncInfo.LatestBlockHeight >= 1
}, time.Minute, time.Second, "Failed to query Consumer node status", err)
s.T().Logf("Consumer node status: %v", consumerStatus.SyncInfo.LatestBlockHeight)

// Wait till IBC connection/channel b/w babylon<->bcd is established
s.waitForIBCConnection()
}

func (s *BCDConsumerIntegrationTestSuite) Test2AutoRegisterAndVerifyNewConsumer() {
Expand Down Expand Up @@ -567,7 +570,7 @@ func (s *BCDConsumerIntegrationTestSuite) initBabylonController() error {
}

// Construct the path to the Makefile directory
cfg.KeyDirectory = filepath.Join(currentDir, "bcd_integration/.testnets/node0/babylond")
cfg.KeyDirectory = filepath.Join(currentDir, "../../contrib/images/bcd/.testnets/node0/babylond")
cfg.GasPrices = "0.02ubbn"
cfg.GasAdjustment = 20

Expand Down Expand Up @@ -606,8 +609,7 @@ func (s *BCDConsumerIntegrationTestSuite) initCosmwasmController() error {
return nil
}

// nolint:unused
func (s *BCDConsumerIntegrationTestSuite) getIBCClientID() string {
func (s *BCDConsumerIntegrationTestSuite) waitForIBCConnection() {
var babylonChannel *channeltypes.IdentifiedChannel
s.Eventually(func() bool {
babylonChannelsResp, err := s.babylonController.IBCChannels()
Expand Down Expand Up @@ -651,27 +653,26 @@ func (s *BCDConsumerIntegrationTestSuite) getIBCClientID() string {
s.T().Logf("IBC channel is established successfully")

// Query the channel client state
babylonChannelState, err := s.babylonController.QueryChannelClientState(babylonChannel.ChannelId, babylonChannel.PortId)
s.Require().NoError(err, "Failed to query Babylon channel client state")

return babylonChannelState.IdentifiedClientState.ClientId
//babylonChannelState, err := s.babylonController.QueryChannelClientState(babylonChannel.ChannelId, babylonChannel.PortId)
//s.Require().NoError(err, "Failed to query Babylon channel client state")
//
//return babylonChannelState.IdentifiedClientState.ClientId
}

func (s *BCDConsumerIntegrationTestSuite) verifyConsumerRegistration(consumerID string) *bsctypes.ConsumerRegister {
var consumerRegistry []*bsctypes.ConsumerRegister
var consumerRegistryResp *bsctypes.QueryConsumersRegistryResponse

s.Eventually(func() bool {
var err error
consumerRegistry, err = s.babylonController.QueryConsumerRegistry(consumerID)
consumerRegistryResp, err = s.babylonController.QueryConsumerRegistry(consumerID)
if err != nil {
s.T().Logf("Error querying consumer registry: %v", err)
return false
}
return len(consumerRegistry) == 1
return consumerRegistryResp != nil && len(consumerRegistryResp.GetConsumersRegister()) == 1
}, time.Minute, 5*time.Second, "Consumer was not registered within the expected time")

s.Require().Len(consumerRegistry, 1)
registeredConsumer := consumerRegistry[0]
registeredConsumer := consumerRegistryResp.GetConsumersRegister()[0]

s.T().Logf("Consumer registered: ID=%s, Name=%s, Description=%s",
registeredConsumer.ConsumerId,
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func TestBTCStakingIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(BTCStakingIntegrationTestSuite))
}

// TestBCDIntegrationTestSuite includes babylon<->bcd integration related tests
func TestBCDIntegrationTestSuite(t *testing.T) {
// TestBCDConsumerIntegrationTestSuite includes babylon<->bcd integration related tests
func TestBCDConsumerIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(BCDConsumerIntegrationTestSuite))
}

Expand Down

0 comments on commit 13ccb90

Please sign in to comment.