tests/

directory
v0.0.0-...-4e9d6c2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 12, 2023 License: Apache-2.0

README

Swamp: In-Memory Test Tool

Swamp is a testing tool that creates an environment for deploying elysium-node and testing instances against each other. While the swamp takes care of setting up networking and initial configuration of node types, the user can focus on tailoring test scenarios.

Usage

Creating a swamp

Calling NewSwamp will return you a new constructed swamp with the mocknet. That function looks like this:

swamp := NewSwamp(t)

The first parameter of the swarm constructor is the testing.T

Constructing Elysium nodes

You can construct any Elysium bridge/full/light nodes using swamp and be rest assured that they will be linked between each other. Note: Linking nodes does not mean that you have connected them. Linking only enables further connection between nodes. Think of linking as a fibre cable between 2 PCs. Connecting is the actual process from the OS level in communicating between them.

// you can add any options during initialization in the signature
bridge := swamp.NewBridgeNode()
Connecting Elysium nodes

In the swamp instance, you can find the Network field that is needed to connect Elysium nodes to each other.

For example, you will need to know the host of the first Elysium node to be able to connect to it from the second one:

addrs, err := peer.AddrInfoToP2pAddrs(host.InfoFromHost(sw.Network.Host(bridge.Host.ID())))
require.NoError(t, err)
light := sw.NewLightClient(node.WithTrustedPeer(addrs[0].String()))

Concenptual overview

Each of the test scenario requires flexibility in network topology. The user can define the necessary amount of each type of node and be able to control each of them. The below diagram provides more visual clarity of what can be done test swamp overview

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL