Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7619597
moved helpers to their own file
May 23, 2023
cc56d3f
mempoolv1 test helpers to new file
May 25, 2023
6380954
moved json rpc helpers to new file
May 25, 2023
b2729ae
goimports
May 25, 2023
d019146
goimportsed test_helpers
May 25, 2023
ce1b76c
test_helpers.go file for node package
May 25, 2023
5e20641
moved more node functions to helpers file
May 26, 2023
8f910ca
store test helpers
May 26, 2023
d11686d
merge main
May 30, 2023
86759d9
goimports store/test_helpers.go
May 30, 2023
5835606
goimports remaining files
May 30, 2023
056c16b
added shared test helpers to new file
May 30, 2023
0ebe4c3
goimports
May 30, 2023
e5f5fbe
Merge branch 'main' into connor/da-test-cleanup
Jun 5, 2023
af75a4c
remove unused variables from tests in the libs/shares package
Jun 5, 2023
17cafe1
merge main
Jun 6, 2023
71db5af
restored name field, since it gets used
Jun 6, 2023
4a9e1b2
initial commit to remove waitGroups from helpers, and callers in full…
Jun 7, 2023
b1d556a
Merge branch 'main' into connor/retries
Jun 8, 2023
814d6ea
created countFunctionCalls helper, to run in a retry.
Jun 8, 2023
b7787cd
replaced waitgroup with a retry
Jun 9, 2023
d493462
merge main
Jun 9, 2023
29c8549
create a MockTester object, allowing us to use the native threadsafe …
Jun 12, 2023
f3d4135
assert NoError for Retry
Jun 12, 2023
483d82d
add celestia utils
Jun 12, 2023
2c4deab
merge main
Jun 12, 2023
1e5e401
go mod tidy
Jun 12, 2023
ee364d3
FraudProofSync test refactored to use retries
Jun 14, 2023
94f43cf
Revert "FraudProofSync test refactored to use retries"
Jun 14, 2023
dce8b04
restored waitgroup to one test
Jun 14, 2023
a481892
test name
Jun 15, 2023
b31ace8
TestLazyAggregator uses retries. much faster
Jun 15, 2023
05e764b
removed 6 seconds of sleeps from testSingleAggregatorSingleFullNodeSi…
Jun 15, 2023
b69b741
Merge branch 'main' into connor/retries
Jun 15, 2023
2a031fc
Merge branch 'main' into connor/retries
Jun 15, 2023
d4bb633
testSingleAggregatorSingleFullNode
Jun 15, 2023
35fbcc2
removed sleeps from testSingleAggregatorTwoFullNode
Jun 15, 2023
6b5a137
refactored the retry helpers
Jun 15, 2023
d4de9dd
improved TrustedHash test
Jun 15, 2023
fbd1655
removed more sleeps
Jun 15, 2023
14fafd6
Merge branch 'main' into connor/retries
Jun 15, 2023
d7cce1c
goimportsed
Jun 15, 2023
2901b28
changed Node receiver to FullNode receiver
Jun 15, 2023
98851ee
removed a sleep from full_node_test
Jun 15, 2023
12c1e48
cleaned up helpers
Jun 20, 2023
3bf4ddc
Revert "cleaned up helpers"
Jun 20, 2023
b3ae53f
clean up waitForFirstBlock
Jun 20, 2023
cb3ae5a
getNodeHeight used for verifyNodesSynced
Jun 20, 2023
8e91b97
Merge branch 'main' into connor/retries
Jun 20, 2023
5be2b12
fix getNodeHeight
Jun 20, 2023
ebd333a
test for MockTester
Jun 20, 2023
130fc44
tests for helpers
Jun 20, 2023
1a6b15f
helper tests in separate file
Jun 20, 2023
3303adf
goimports
Jun 20, 2023
51e5950
remove a clunky waitgroup from full_client_test.go
Jun 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/celestiaorg/go-cnc v0.3.0
github.com/celestiaorg/go-fraud v0.1.0
github.com/celestiaorg/go-header v0.2.8
github.com/celestiaorg/utils v0.1.0
github.com/dgraph-io/badger/v3 v3.2103.5
github.com/go-kit/kit v0.12.0
github.com/gogo/protobuf v1.3.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ github.com/celestiaorg/go-header v0.2.8 h1:NS6fOzfRoGqQF3RrstSjAxLArWyJWob+25T4G
github.com/celestiaorg/go-header v0.2.8/go.mod h1:i9OpY70+PJ1xPw1IgMfF0Pk6vBD6VWPmjY3bgubJBcU=
github.com/celestiaorg/go-libp2p-messenger v0.2.0 h1:/0MuPDcFamQMbw9xTZ73yImqgTO3jHV7wKHvWD/Irao=
github.com/celestiaorg/go-libp2p-messenger v0.2.0/go.mod h1:s9PIhMi7ApOauIsfBcQwbr7m+HBzmVfDIS+QLdgzDSo=
github.com/celestiaorg/utils v0.1.0 h1:WsP3O8jF7jKRgLNFmlDCwdThwOFMFxg0MnqhkLFVxPo=
github.com/celestiaorg/utils v0.1.0/go.mod h1:vQTh7MHnvpIeCQZ2/Ph+w7K1R2UerDheZbgJEJD2hSU=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc=
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4/go.mod h1:fzuHnhzj1pUygGz+1ZkB3uQbEUL4htqCGJ4Qs2LwMZA=
github.com/celestiaorg/nmt v0.15.0 h1:ID9QlMIeP6WK/iiGcfnYLu2qqVIq0UYe/dc3TVPt6EA=
Expand Down
38 changes: 23 additions & 15 deletions node/full_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package node
import (
"context"
crand "crypto/rand"
"errors"
"fmt"
"math/rand"
"sync"
"testing"
"time"

testutils "github.com/celestiaorg/utils/test"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -764,7 +766,7 @@ func TestBlockchainInfo(t *testing.T) {
}
}

func createGenesisValidators(numNodes int, appCreator func(require *require.Assertions, vKeyToRemove tmcrypto.PrivKey, wg *sync.WaitGroup) *mocks.Application, require *require.Assertions, wg *sync.WaitGroup) *FullClient {
func createGenesisValidators(numNodes int, appCreator func(require *require.Assertions, vKeyToRemove tmcrypto.PrivKey) *mocks.Application, require *require.Assertions) (*FullClient, *mocks.Application) {
vKeys := make([]tmcrypto.PrivKey, numNodes)
apps := make([]*mocks.Application, numNodes)
nodes := make([]*FullNode, numNodes)
Expand All @@ -773,8 +775,7 @@ func createGenesisValidators(numNodes int, appCreator func(require *require.Asse
for i := 0; i < len(vKeys); i++ {
vKeys[i] = ed25519.GenPrivKey()
genesisValidators[i] = tmtypes.GenesisValidator{Address: vKeys[i].PubKey().Address(), PubKey: vKeys[i].PubKey(), Power: int64(i + 100), Name: fmt.Sprintf("gen #%d", i)}
apps[i] = appCreator(require, vKeys[0], wg)
wg.Add(1)
apps[i] = appCreator(require, vKeys[0])
}

dalc := &mockda.DataAvailabilityLayerClient{}
Expand Down Expand Up @@ -822,7 +823,7 @@ func createGenesisValidators(numNodes int, appCreator func(require *require.Asse
err := nodes[i].Start()
require.NoError(err)
}
return rpc
return rpc, apps[0]
}

func checkValSet(rpc *FullClient, assert *assert.Assertions, h int64, expectedValCount int) {
Expand All @@ -843,7 +844,7 @@ func checkValSetLatest(rpc *FullClient, assert *assert.Assertions, lastBlockHeig
assert.GreaterOrEqual(vals.BlockHeight, lastBlockHeight)
}

func createApp(require *require.Assertions, vKeyToRemove tmcrypto.PrivKey, wg *sync.WaitGroup) *mocks.Application {
func createApp(require *require.Assertions, vKeyToRemove tmcrypto.PrivKey) *mocks.Application {
app := &mocks.Application{}
app.On("InitChain", mock.Anything).Return(abci.ResponseInitChain{})
app.On("CheckTx", mock.Anything).Return(abci.ResponseCheckTx{})
Expand All @@ -860,9 +861,7 @@ func createApp(require *require.Assertions, vKeyToRemove tmcrypto.PrivKey, wg *s
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{}).Once()
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{ValidatorUpdates: []abci.ValidatorUpdate{{PubKey: pbValKey, Power: 100}}}).Once()
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{}).Times(5)
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{}).Run(func(args mock.Arguments) {
wg.Done()
}).Once()
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{}).Once()
app.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{})
return app
}
Expand All @@ -872,12 +871,16 @@ func TestValidatorSetHandling(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

var wg sync.WaitGroup

numNodes := 2
rpc := createGenesisValidators(numNodes, createApp, require, &wg)
rpc, app := createGenesisValidators(numNodes, createApp, require)

wg.Wait()
m := MockTester{t: t}
require.NoError(testutils.Retry(300, 100*time.Millisecond, func() error {
if app.AssertNumberOfCalls(m, "EndBlock", 11) {
return nil
}
return errors.New("EndBlock not called 11 times")
}))

// test first blocks
for h := int64(1); h <= 3; h++ {
Expand All @@ -903,11 +906,16 @@ func TestValidatorSetHandlingBased(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

var wg sync.WaitGroup
numNodes := 1
rpc := createGenesisValidators(numNodes, createApp, require, &wg)
rpc, app := createGenesisValidators(numNodes, createApp, require)

wg.Wait()
m := MockTester{t: t}
require.NoError(testutils.Retry(300, 100*time.Millisecond, func() error {
if app.AssertNumberOfCalls(m, "EndBlock", 11) {
return nil
}
return errors.New("EndBlock not called 11 times")
}))

time.Sleep(100 * time.Millisecond)

Expand Down
Loading