Skip to content

Commit

Permalink
fix(gosdk): tests parallel race condition (#1904)
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine authored May 31, 2024
1 parent f881f82 commit e7e708d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
19 changes: 10 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ module github.com/NibiruChain/nibiru
go 1.21

require (
cosmossdk.io/api v0.7.0 // indirect
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d
github.com/CosmWasm/wasmd v0.44.0
github.com/CosmWasm/wasmvm v1.5.0
github.com/MakeNowJust/heredoc/v2 v2.0.1
github.com/NibiruChain/collections v0.5.0

// Consenus Engine
Expand All @@ -19,15 +14,21 @@ require (
// Cosmos-SDK and IBC
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.47.11
github.com/cosmos/gogoproto v1.4.10
github.com/cosmos/ibc-go/v7 v7.3.2
github.com/ethereum/go-ethereum v1.10.17
)

// Else
github.com/cosmos/go-bip39 v1.0.0
require (
cosmossdk.io/api v0.7.0 // indirect
cosmossdk.io/errors v1.0.1
cosmossdk.io/math v1.3.0
cosmossdk.io/simapp v0.0.0-20230608160436-666c345ad23d
github.com/MakeNowJust/heredoc/v2 v2.0.1
github.com/armon/go-metrics v0.4.1
github.com/btcsuite/btcd v0.24.0
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/ethereum/go-ethereum v1.10.17
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.4.10
github.com/gogo/protobuf v1.3.3
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.4
Expand Down
13 changes: 7 additions & 6 deletions gosdk/gosdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *TestSuite) RPCEndpoint() string {
// SetupSuite implements the suite.SetupAllSuite interface. This function runs
// prior to all of the other tests in the suite.
func (s *TestSuite) SetupSuite() {
// testutil.BeforeIntegrationSuite(s.T())
testutil.BeforeIntegrationSuite(s.T())

nibiru, err := gosdk.CreateBlockchain(s.T())
s.NoError(err)
Expand All @@ -68,7 +68,7 @@ func (s *TestSuite) ConnectGrpc() {
s.grpcConn = grpcConn
}

func (s *TestSuite) TestNewQueryClient() {
func (s *TestSuite) DoTestNewQueryClient() {
_, err := gosdk.NewQuerier(s.grpcConn)
s.NoError(err)
}
Expand All @@ -80,13 +80,14 @@ func (s *TestSuite) TestNewNibiruSdk() {
s.nibiruSdk = &nibiruSdk

s.nibiruSdk.Keyring = s.val.ClientCtx.Keyring
s.T().Run("DoTestBroadcastMsgs", func(t *testing.T) {
s.DoTestBroadcastMsgs()
})
s.T().Run("DoTestBroadcastMsgsGrpc", func(t *testing.T) {

s.Run("DoTestBroadcastMsgs", func() { s.DoTestBroadcastMsgs() })
s.Run("DoTestBroadcastMsgsGrpc", func() {
s.NoError(s.network.WaitForNextBlock())
s.DoTestBroadcastMsgsGrpc()
})
s.Run("DoTestNewQueryClient", s.DoTestNewQueryClient)
s.Run("DoTestSequenceExpectations", s.DoTestSequenceExpectations)
}

// FIXME: Q: What is the node home for a local validator?
Expand Down
6 changes: 3 additions & 3 deletions gosdk/sequence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import (
"github.com/NibiruChain/nibiru/gosdk"
)

// TestSequenceExpectations validates the behavior of account sequence numbers
// DoTestSequenceExpectations validates the behavior of account sequence numbers
// and transaction finalization in a blockchain network. It ensures that sequence
// numbers increment correctly with each transaction and that transactions can be
// queried successfully after the blocks are completed.
func (s *TestSuite) TestSequenceExpectations() {
func (s *TestSuite) DoTestSequenceExpectations() {
t := s.T()
t.Log("Get sequence and block")
// Go to next block
Expand Down Expand Up @@ -73,6 +73,6 @@ func (s *TestSuite) TestSequenceExpectations() {
s.T().Log("Query each tx by hash (successfully)")
for txHashHex := range txResults {
_, err := s.nibiruSdk.TxByHash(txHashHex)
s.NoError(err)
s.Require().NoError(err)
}
}

0 comments on commit e7e708d

Please sign in to comment.