forked from ten-protocol/go-ten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
simulation_full_network_test.go
40 lines (31 loc) · 1.61 KB
/
simulation_full_network_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package simulation
import (
"testing"
"time"
"github.com/obscuronet/go-obscuro/integration"
"github.com/obscuronet/go-obscuro/integration/simulation/params"
"github.com/obscuronet/go-obscuro/integration/simulation/network"
)
// This test creates a network of L2 nodes, then injects transactions, and finally checks the resulting output blockchain.
// The L2 nodes communicate with each other via sockets, and with their enclave servers via RPC.
// All nodes and enclaves live in the same process. The L1 network is a private geth network using Clique (PoA).
func TestFullNetworkMonteCarloSimulation(t *testing.T) {
setupSimTestLog("full-network")
numberOfNodes := 5
numberOfSimWallets := 5
wallets := params.NewSimWallets(numberOfSimWallets, numberOfNodes, integration.EthereumChainID, integration.ObscuroChainID)
simParams := ¶ms.SimParams{
NumberOfNodes: numberOfNodes,
AvgBlockDuration: 1 * time.Second,
SimulationTime: 45 * time.Second,
L1EfficiencyThreshold: 0.2,
// Very hard to have precision here as blocks are continually produced and not dependent on the simulation execution thread
L2EfficiencyThreshold: 0.75, // nodes might produce rollups because they receive a new block
L2ToL1EfficiencyThreshold: 0.7, // nodes might stop producing rollups but the geth network is still going
Wallets: wallets,
StartPort: integration.StartPortSimulationFullNetwork,
ReceiptTimeout: 30 * time.Second,
}
simParams.AvgNetworkLatency = simParams.AvgBlockDuration / 15
testSimulation(t, network.NewNetworkOfSocketNodes(wallets), simParams)
}