Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network tests: basic sim to run in CI builds #1833

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 integration/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
StartPortSimulationGethInMem = 18000
StartPortSimulationInMem = 22000
StartPortSimulationFullNetwork = 26000
StartPortNetworkTests = 28000
StartPortSmartContractTests = 30000
StartPortContractDeployerTest1 = 34000
StartPortContractDeployerTest2 = 35000
Expand Down
4 changes: 2 additions & 2 deletions integration/networktest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ These tests require a network that provides access to its nodes through the `Nod

They can be used to test scenarios such as rejoining the network after a restart, sequencer failover, nodes losing connectivity.

### `/ci` (coming soon)
These are the only ones that will run during the CI builds by default, they should be quick and not fragile.
### `/ci`
These are the only tests that will run during the CI builds by default, they should be quick and not fragile.

## UserWallet
In `/userwallet` is a high-level client that bundles a simulated user's private key, an RPC client and manages the nonce and viewing key.
Expand Down
26 changes: 26 additions & 0 deletions integration/networktest/tests/ci/simulation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ci

import (
"testing"
"time"

"github.com/ten-protocol/go-ten/integration/networktest"
"github.com/ten-protocol/go-ten/integration/networktest/actions"
"github.com/ten-protocol/go-ten/integration/networktest/env"
)

// TestSimulation spins up a local network and runs some activity on it, verifying the results.
// This is useful for testing the network in a more realistic scenario, we will extend this to include more complex tests.
func TestSimulation(t *testing.T) {
networktest.Run(
"ci-simulation-test",
t,
env.LocalDevNetwork(),
actions.Series(
actions.CreateAndFundTestUsers(25),
actions.GenerateUsersRandomisedTransferActionsInParallel(5, 10*time.Second),

actions.VerifyUserBalancesSanity(),
),
)
}
6 changes: 3 additions & 3 deletions integration/simulation/devnetwork/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func DefaultDevNetwork(tenGateway bool) *InMemDevNetwork {
numNodes := 4 // Default sim currently uses 4 L1 nodes. Obscuro nodes: 1 seq, 3 validators
networkWallets := params.NewSimWallets(0, numNodes, integration.EthereumChainID, integration.TenChainID)
l1Config := &L1Config{
PortStart: integration.StartPortSimulationFullNetwork,
PortStart: integration.StartPortNetworkTests,
NumNodes: 4,
AvgBlockDuration: 1 * time.Second,
}
Expand All @@ -50,7 +50,7 @@ func DefaultDevNetwork(tenGateway bool) *InMemDevNetwork {
networkWallets: networkWallets,
l1Network: l1Network,
obscuroConfig: ObscuroConfig{
PortStart: integration.StartPortSimulationFullNetwork,
PortStart: integration.StartPortNetworkTests,
InitNumValidators: 3,
BatchInterval: 1 * time.Second,
RollupInterval: 10 * time.Second,
Expand Down Expand Up @@ -92,7 +92,7 @@ func LiveL1DevNetwork(seqWallet wallet.Wallet, validatorWallets []wallet.Wallet,
networkWallets: networkWallets,
l1Network: l1Network,
obscuroConfig: ObscuroConfig{
PortStart: integration.StartPortSimulationFullNetwork,
PortStart: integration.StartPortNetworkTests,
InitNumValidators: len(validatorWallets),
BatchInterval: 5 * time.Second,
RollupInterval: 3 * time.Minute,
Expand Down
Loading