Skip to content

Commit

Permalink
Merge branch 'main' into ud/ban-wasm-to-evm
Browse files Browse the repository at this point in the history
  • Loading branch information
Unique-Divine authored Jan 11, 2025
2 parents 3d41225 + 8db476f commit be62c0a
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ needed to include double quotes around the hexadecimal string.
- [#2157](https://github.com/NibiruChain/nibiru/pull/2157) - fix(evm): Fix unit inconsistency related to AuthInfo.Fee and txData.Fee using effective fee
- [#2159](https://github.com/NibiruChain/nibiru/pull/2159) - chore(evm): Augment the Wasm msg handler so that wasm contracts cannot send MsgEthereumTx
- [#2160](https://github.com/NibiruChain/nibiru/pull/2160) - fix(evm-precompile): use bank.MsgServer Send in precompile IFunToken.bankMsgSend
- [#2162](https://github.com/NibiruChain/nibiru/pull/2162) - test(testutil): try retrying for 'panic: pebbledb: closed'

#### Nibiru EVM | Before Audit 2 - 2024-12-06

Expand Down
4 changes: 3 additions & 1 deletion app/wasmext/wasm_cli_test/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,7 @@ func (s *TestSuite) requiredDeployedContractsLen(total int) {
}

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(TestSuite))
testutil.RetrySuiteRunIfDbClosed(t, func() {
suite.Run(t, new(TestSuite))
}, 2)
}
5 changes: 4 additions & 1 deletion eth/rpc/rpcapi/eth_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ type NodeSuite struct {

func TestSuite_RunAll(t *testing.T) {
suite.Run(t, new(Suite))
suite.Run(t, new(NodeSuite))

testutil.RetrySuiteRunIfDbClosed(t, func() {
suite.Run(t, new(NodeSuite))
}, 2)
}

// SetupSuite runs before every test in the suite. Implements the
Expand Down
38 changes: 38 additions & 0 deletions x/common/testutil/cases.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package testutil

import (
"strings"
"testing"
)

Expand Down Expand Up @@ -34,3 +35,40 @@ func BeforeIntegrationSuite(suiteT *testing.T) {
}
suiteT.Log("setting up integration test suite")
}

// RetrySuiteRunIfDbClosed runs a test suite with retries, recovering from a
// specific panic message, "pebbledb: closed" that often surfaces in CI when tests
// involve "Nibiru/x/common/testutil/testnetwork".
// For full context, see https://github.com/NibiruChain/nibiru/issues/1918.
func RetrySuiteRunIfDbClosed(t *testing.T, runTest func(), maxRetries int) {
panicMessage := "pebbledb: closed"
for attempt := 0; attempt < maxRetries; attempt++ {
panicked := false

func() {
defer func() {
if r := recover(); r != nil {
if errMsg, ok := r.(string); ok && strings.Contains(errMsg, panicMessage) {
t.Logf("Recovered from panic on attempt %d: %v", attempt, r)
panicked = true
} else {
panic(r) // Re-panic if it's not the specific error
}
}
}()

// Run the test suite
runTest()
// suite.Run(t, suiteInstance)
}()

if !panicked {
t.Logf("Test suite succeeded on attempt %d", attempt)
return
}

t.Logf("Retrying test suite: attempt %d", attempt+1)
}

t.Fatalf("Test suite failed after %d attempts due to '%s'", maxRetries, panicMessage)
}
4 changes: 3 additions & 1 deletion x/common/testutil/testnetwork/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ import (
)

func TestIntegrationTestSuite_RunAll(t *testing.T) {
suite.Run(t, new(TestSuite))
testutil.RetrySuiteRunIfDbClosed(t, func() {
suite.Run(t, new(TestSuite))
}, 2)
}

// Assert network cleanup
Expand Down
4 changes: 3 additions & 1 deletion x/oracle/keeper/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ func (s *TestSuite) currentPrices() map[asset.Pair]sdk.Dec {
}

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(TestSuite))
testutil.RetrySuiteRunIfDbClosed(t, func() {
suite.Run(t, new(TestSuite))
}, 2)
}

func (s *TestSuite) TearDownSuite() {
Expand Down
4 changes: 3 additions & 1 deletion x/sudo/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ type Account struct {
}

func TestSuite_IntegrationSuite_RunAll(t *testing.T) {
suite.Run(t, new(TestSuite))
testutil.RetrySuiteRunIfDbClosed(t, func() {
suite.Run(t, new(TestSuite))
}, 2)
}

// ———————————————————————————————————————————————————————————————————
Expand Down
4 changes: 3 additions & 1 deletion x/tokenfactory/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ type TestSuite struct {
}

func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(TestSuite))
testutil.RetrySuiteRunIfDbClosed(t, func() {
suite.Run(t, new(TestSuite))
}, 2)
}

// TestTokenFactory: Runs the test suite with a deterministic order.
Expand Down

0 comments on commit be62c0a

Please sign in to comment.