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

Convert e2e tmpnet #1249

Merged
merged 51 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c40ddf5
Remove TokenVM
aaronbuchwald Jul 22, 2024
7095be0
Remove tokenvm from CI/scripts/README
aaronbuchwald Jul 22, 2024
7bca597
Start e2e test refactor with workload logic decoupled from test decla…
aaronbuchwald Jul 22, 2024
cfea536
Move sync test w/ TODOs into e2e
aaronbuchwald Jul 24, 2024
809053b
fix lint
aaronbuchwald Jul 24, 2024
f45adce
Add GenerateNBlocks helper
aaronbuchwald Jul 24, 2024
0ebbf5b
fix lint
aaronbuchwald Jul 24, 2024
05dfb9c
fix count dec instead of inc
aaronbuchwald Jul 25, 2024
a8838d3
Re-add state sync
aaronbuchwald Jul 25, 2024
0a0b43e
fmt
aaronbuchwald Jul 25, 2024
fada80c
Mark sync tests as pending
aaronbuchwald Jul 25, 2024
7ed84e0
fix lint
aaronbuchwald Jul 25, 2024
97a28c4
Fix VMConfigPath -> VMConfig
aaronbuchwald Jul 25, 2024
d2d4eea
Add GenerateUntilCancel to handle concurrent sync + broadcast test case
aaronbuchwald Jul 26, 2024
a921cf0
remove single line stop script
aaronbuchwald Jul 26, 2024
7c40180
fix shellcheck
aaronbuchwald Jul 26, 2024
9bbef65
Skip syncing test
aaronbuchwald Jul 26, 2024
51de41e
Allow errors during broadcast txs while syncing
aaronbuchwald Jul 26, 2024
8795540
fix lint
aaronbuchwald Jul 26, 2024
f02817c
move sync test back to separate job with higher timeout
aaronbuchwald Jul 28, 2024
edd119c
fix gh action yml
aaronbuchwald Jul 28, 2024
03fa1af
cleanup
aaronbuchwald Jul 28, 2024
57a9b4e
Add passthrough args + ginkgo focus ping on mode=run
aaronbuchwald Jul 28, 2024
712f91f
fix lint
aaronbuchwald Jul 28, 2024
3f5aa22
fix unbound bash var
aaronbuchwald Jul 28, 2024
feb0c68
Rename map util combinators
aaronbuchwald Jul 29, 2024
84b1853
Merge branch 'main' into start-e2e-test-refactor
aaronbuchwald Jul 29, 2024
7bf3ef3
Merge branch 'main' into start-e2e-test-refactor
aaronbuchwald Jul 31, 2024
78505f6
Refactor e2e tests to use tmpnet
aaronbuchwald Jul 31, 2024
e4f27bd
Address nits
aaronbuchwald Aug 1, 2024
a8f3216
Update workload factory interface
aaronbuchwald Aug 2, 2024
58b6987
Remove unnecessary ctx w/ timeout
aaronbuchwald Aug 2, 2024
54c60f7
Replace describe with it
aaronbuchwald Aug 2, 2024
6a4e3ee
Merge branch 'start-e2e-test-refactor' into convert-e2e-tmpnet
aaronbuchwald Aug 2, 2024
2007094
Merge branch 'main' into convert-e2e-tmpnet
aaronbuchwald Aug 5, 2024
50f8e1a
fix merge
aaronbuchwald Aug 5, 2024
f78f838
Update describe/it
aaronbuchwald Aug 5, 2024
28b3596
add explicit longer context timeout than default (#1251)
iFrostizz Aug 5, 2024
029c797
adjust timeout, balance, fees (#1262)
iFrostizz Aug 8, 2024
dd3e830
defer cancel in state sync while broadcasting txs
aaronbuchwald Aug 8, 2024
8e033d1
Update action timeout
aaronbuchwald Aug 8, 2024
4e01e9b
bump ago to tmpnet fix for subnet config
aaronbuchwald Aug 12, 2024
3436987
Update e2e tests timeout back to 25m
aaronbuchwald Aug 12, 2024
829bc1f
Update ago version to match go mod
aaronbuchwald Aug 12, 2024
4e48c57
Merge branch 'main' into convert-e2e-tmpnet
aaronbuchwald Aug 12, 2024
617d70c
fix stop script
aaronbuchwald Aug 13, 2024
69c56de
Move entrypoint to morpheusvm test file
aaronbuchwald Aug 13, 2024
bd3dbe0
Merge branch 'main' into convert-e2e-tmpnet
aaronbuchwald Aug 13, 2024
d133298
fix lint
aaronbuchwald Aug 13, 2024
a4ad301
bump to ago commit on master
aaronbuchwald Aug 13, 2024
479b2e9
Add comments to WindowTargetUnits and MaxBlockUnits values in genesis…
aaronbuchwald Aug 13, 2024
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
4 changes: 2 additions & 2 deletions examples/morpheusvm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The first step to running this demo is to launch your own `morpheusvm` Subnet. Y
can do so by running the following command from this location (may take a few
minutes):
```bash
killall avalanche-network-runner
./scripts/run.sh
```

When the Subnet is running, you'll see the following logs emitted:
Expand All @@ -38,7 +38,7 @@ avalanche-network-runner is running in the background...

use the following command to terminate:

./scripts/stop.sh;
killall avalanche-network-runner
```

_By default, this allocates all funds on the network to `morpheus1qrzvk4zlwj9zsacqgtufx7zvapd3quufqpxk5rsdd4633m4wz2fdjk97rwu`. The private
Expand Down
4 changes: 2 additions & 2 deletions examples/morpheusvm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ava-labs/hypersdk/examples/morpheusvm
go 1.21.12

require (
github.com/ava-labs/avalanchego v1.11.11-0.20240731061259-4945ee27f820
github.com/ava-labs/avalanchego v1.11.11-0.20240802190725-62a44e63cee0
github.com/ava-labs/hypersdk v0.0.1
github.com/fatih/color v1.13.0
github.com/onsi/ginkgo/v2 v2.13.1
Expand All @@ -19,7 +19,7 @@ require (
github.com/NYTimes/gziphandler v1.1.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0 // indirect
github.com/ava-labs/coreth v0.13.7 // indirect
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions examples/morpheusvm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0 h1:xNbCMNqenaDr0bb35j27sqwa+C8t8BgRz51vXd6q0QM=
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0/go.mod h1:B7Ynk/avkCk49CCIWbM4j1UrPlqIi0IHCPAB2MZNvLw=
github.com/ava-labs/avalanchego v1.11.11-0.20240731061259-4945ee27f820 h1:KYZbf4zffMF9xEJevCOjXlIXsanYHU5skzxrgc1Xhko=
github.com/ava-labs/avalanchego v1.11.11-0.20240731061259-4945ee27f820/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g=
github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/avalanchego v1.11.11-0.20240802190725-62a44e63cee0 h1:/g8YWnNWPzKNsHxd7i7DjnpNqnjA/sa8zrU+VeCA8/E=
github.com/ava-labs/avalanchego v1.11.11-0.20240802190725-62a44e63cee0/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d h1:klPTcKVvqfA2KSKaRvQAO56Pd4XAqGhwgMTQ6/W+w7w=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
2 changes: 1 addition & 1 deletion examples/morpheusvm/scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source ../../scripts/constants.sh
# shellcheck source=/scripts/common/utils.sh
source ../../scripts/common/utils.sh

VERSION=4945ee27f820115167d7a5551975099be14af911
VERSION=62a44e63cee021749bf02c6b92064441dcfd09fd

############################
# build avalanchego
Expand Down
5 changes: 3 additions & 2 deletions examples/morpheusvm/tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ type workloadFactory struct {
factory *auth.ED25519Factory
}

func (f *workloadFactory) NewBasicTxWorkload(uri string) (workload.TxWorkloadIterator, error) {
return f.NewSizedTxWorkload(uri, 1)
func (f *workloadFactory) NewWorkloads(uri string) ([]workload.TxWorkloadIterator, error) {
basicTxWorkload, err := f.NewSizedTxWorkload(uri, 1)
return []workload.TxWorkloadIterator{basicTxWorkload}, err
}

func (f *workloadFactory) NewSizedTxWorkload(uri string, size int) (workload.TxWorkloadIterator, error) {
Expand Down
4 changes: 2 additions & 2 deletions examples/morpheusvm/tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/consensus/snowman"
"github.com/ava-labs/avalanchego/snow/engine/common"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/snow/validators/validatorstest"
"github.com/ava-labs/avalanchego/utils/crypto/bls"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
Expand Down Expand Up @@ -206,7 +206,7 @@ var _ = ginkgo.BeforeSuite(func() {
ChainDataDir: dname,
Metrics: metrics.NewPrefixGatherer(),
PublicKey: bls.PublicFromSecretKey(sk),
ValidatorState: &validators.TestState{},
ValidatorState: &validatorstest.TestState{},
}

toEngine := make(chan common.Message, 1)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/NYTimes/gziphandler v1.1.1
github.com/akamensky/argparse v1.4.0
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0
github.com/ava-labs/avalanchego v1.11.11-0.20240731061259-4945ee27f820
github.com/ava-labs/avalanchego v1.11.11-0.20240802190725-62a44e63cee0
github.com/btcsuite/btcd/btcutil v1.1.3
github.com/bytecodealliance/wasmtime-go/v14 v14.0.0
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
filippo.io/edwards25519 v1.0.0 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/ava-labs/coreth v0.13.7 // indirect
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0 h1:xNbCMNqenaDr0bb35j27sqwa+C8t8BgRz51vXd6q0QM=
github.com/ava-labs/avalanche-network-runner v1.7.4-rc.0/go.mod h1:B7Ynk/avkCk49CCIWbM4j1UrPlqIi0IHCPAB2MZNvLw=
github.com/ava-labs/avalanchego v1.11.11-0.20240731061259-4945ee27f820 h1:KYZbf4zffMF9xEJevCOjXlIXsanYHU5skzxrgc1Xhko=
github.com/ava-labs/avalanchego v1.11.11-0.20240731061259-4945ee27f820/go.mod h1:POgZPryqe80OeHCDNrXrPOKoFre736iFuMgmUBeKaLc=
github.com/ava-labs/coreth v0.13.7 h1:k8T9u/ROifl8f7oXjHRc1KvSISRl9txvy7gGVmHEz6g=
github.com/ava-labs/coreth v0.13.7/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/ava-labs/avalanchego v1.11.11-0.20240802190725-62a44e63cee0 h1:/g8YWnNWPzKNsHxd7i7DjnpNqnjA/sa8zrU+VeCA8/E=
github.com/ava-labs/avalanchego v1.11.11-0.20240802190725-62a44e63cee0/go.mod h1:9e0UPXJboybmgFjeTj+SFbK4ugbrdG4t68VdiUW5oQ8=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d h1:klPTcKVvqfA2KSKaRvQAO56Pd4XAqGhwgMTQ6/W+w7w=
github.com/ava-labs/coreth v0.13.8-0.20240802110637-b3e5088d062d/go.mod h1:tXDujonxXFOF6oK5HS2EmgtSXJK3Gy6RpZxb5WzR9rM=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
79 changes: 46 additions & 33 deletions tests/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"time"

"github.com/ava-labs/avalanchego/api/info"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/tests"
"github.com/ava-labs/avalanchego/tests/fixture/e2e"
Expand All @@ -29,7 +30,6 @@ var (
vmID ids.ID
genesisBytes []byte
txWorkloadFactory workload.TxWorkloadFactory
networkID uint32
blockchainID ids.ID
flagVars *e2e.FlagVars
)
Expand Down Expand Up @@ -70,7 +70,6 @@ var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {

// Initialize the local test environment from the global state
e2e.InitSharedTestEnvironment(ginkgo.GinkgoT(), envBytes)
networkID = e2e.GetEnv(e2e.NewTestContext()).GetNetwork().NetworkID
blockchainID = e2e.GetEnv(e2e.NewTestContext()).GetNetwork().GetSubnet(vmName).Chains[0].ChainID
})

Expand All @@ -79,74 +78,81 @@ var _ = ginkgo.Describe("[HyperSDK APIs]", func() {
require := require.New(tc)

ginkgo.It("Ping", func() {
workload.Ping(tc.DefaultContext(), require, getE2EURIs(tc))
workload.Ping(tc.DefaultContext(), require, getE2EURIs(tc, blockchainID))
})

ginkgo.It("GetNetwork", func() {
workload.GetNetwork(tc.DefaultContext(), require, getE2EURIs(tc), networkID, blockchainID)
baseURIs := getE2EBaseURIs(tc)
baseURI := baseURIs[0]
client := info.NewClient(baseURI)
aaronbuchwald marked this conversation as resolved.
Show resolved Hide resolved
expectedNetworkID, err := client.GetNetworkID(tc.DefaultContext())
require.NoError(err)
workload.GetNetwork(tc.DefaultContext(), require, getE2EURIs(tc, blockchainID), expectedNetworkID, blockchainID)
})
})

var _ = ginkgo.Describe("[HyperSDK Basic Tx Workload]", func() {
var _ = ginkgo.Describe("[HyperSDK Tx Workloads]", func() {
ginkgo.It("Basic Tx Workload", func() {
tc := e2e.NewTestContext()
require := require.New(tc)

txs, err := txWorkloadFactory.NewBasicTxWorkload(getE2EURIs(tc)[0])
txWorkloads, err := txWorkloadFactory.NewWorkloads(getE2EURIs(tc, blockchainID)[0])
require.NoError(err)
workload.ExecuteWorkload(tc.DefaultContext(), require, getE2EURIs(tc), txs)
for _, txWorkload := range txWorkloads {
workload.ExecuteWorkload(tc.DefaultContext(), require, getE2EURIs(tc, blockchainID), txWorkload)
}
})
})

var _ = ginkgo.Describe("[HyperSDK Syncing]", func() {
var _ = ginkgo.It("[HyperSDK Syncing]", func() {
tc := e2e.NewTestContext()
require := require.New(tc)

uris := getE2EURIs(tc)
ginkgo.It("Generate 128 blocks", func() {
uris := getE2EURIs(tc, blockchainID)
ginkgo.By("Generate 128 blocks", func() {
workload.GenerateNBlocks(tc.DefaultContext(), require, uris, txWorkloadFactory, 128)
})

var (
bootstrapNode *tmpnet.Node
bootstrapNodeURI string
)
ginkgo.It("Start a new node to bootstrap", func() {
bootstrapNode = bootstrapNewHyperNode(tc)
ginkgo.By("Start a new node to bootstrap", func() {
bootstrapNode = e2e.CheckBootstrapIsPossible(tc, e2e.GetEnv(tc).GetNetwork())
bootstrapNodeURI = formatURI(bootstrapNode.URI, blockchainID)
uris = append(uris, bootstrapNodeURI)
})
ginkgo.It("Accept a transaction after state sync", func() {
ginkgo.By("Accept a transaction after state sync", func() {
txWorkload, err := txWorkloadFactory.NewSizedTxWorkload(bootstrapNodeURI, 1)
require.NoError(err)
workload.ExecuteWorkload(tc.DefaultContext(), require, uris, txWorkload)
})
ginkgo.It("Restart the node", func() {
ginkgo.By("Restart the node", func() {
require.NoError(e2e.GetEnv(tc).GetNetwork().RestartNode(tc.DefaultContext(), ginkgo.GinkgoWriter, bootstrapNode))
})
ginkgo.It("Generate 1024 blocks", func() {
ginkgo.By("Generate 1024 blocks", func() {
workload.GenerateNBlocks(tc.DefaultContext(), require, uris, txWorkloadFactory, 1024)
})
var (
syncNode *tmpnet.Node
syncNodeURI string
)
ginkgo.It("Start a new node to state sync", func() {
syncNode = bootstrapNewHyperNode(tc)
ginkgo.By("Start a new node to state sync", func() {
syncNode = e2e.CheckBootstrapIsPossible(tc, e2e.GetEnv(tc).GetNetwork())
syncNodeURI = formatURI(syncNode.URI, blockchainID)
uris = append(uris, syncNodeURI)
utils.Outf("{{blue}}sync node uri: %s{{/}}\n", syncNodeURI)
c := rpc.NewJSONRPCClient(syncNodeURI)
_, _, _, err := c.Network(tc.DefaultContext())
require.NoError(err)
})
ginkgo.It("Accept a transaction after state sync", func() {
ginkgo.By("Accept a transaction after state sync", func() {
txWorkload, err := txWorkloadFactory.NewSizedTxWorkload(syncNodeURI, 1)
require.NoError(err)
workload.ExecuteWorkload(tc.DefaultContext(), require, uris, txWorkload)
})
ginkgo.It("Pause the node", func() {
// TODO: can we remove the need to call SaveAPIPort from the test
ginkgo.By("Pause the node", func() {
// TODO: remove the need to call SaveAPIPort from the test
require.NoError(syncNode.SaveAPIPort())
require.NoError(syncNode.Stop(tc.DefaultContext()))

Expand All @@ -156,12 +162,12 @@ var _ = ginkgo.Describe("[HyperSDK Syncing]", func() {
require.Error(err) //nolint:forbidigo
require.False(ok)
})
ginkgo.It("Generate 256 blocks", func() {
ginkgo.By("Generate 256 blocks", func() {
// Generate blocks on all nodes except the paused node
runningURIs := uris[:len(uris)-1]
workload.GenerateNBlocks(tc.DefaultContext(), require, runningURIs, txWorkloadFactory, 256)
})
ginkgo.It("Resume the node", func() {
ginkgo.By("Resume the node", func() {
require.NoError(e2e.GetEnv(tc).GetNetwork().StartNode(tc.DefaultContext(), ginkgo.GinkgoWriter, syncNode))
utils.Outf("Waiting for sync node to restart")
require.NoError(tmpnet.WaitForHealthy(tc.DefaultContext(), syncNode))
Expand All @@ -173,12 +179,12 @@ var _ = ginkgo.Describe("[HyperSDK Syncing]", func() {
require.NoError(err)
})

ginkgo.It("Accept a transaction after resuming", func() {
ginkgo.By("Accept a transaction after resuming", func() {
txWorkload, err := txWorkloadFactory.NewSizedTxWorkload(syncNodeURI, 1)
require.NoError(err)
workload.ExecuteWorkload(tc.DefaultContext(), require, uris, txWorkload)
})
ginkgo.It("State sync while broadcasting txs", func() {
ginkgo.By("State sync while broadcasting txs", func() {
ctx, cancel := context.WithCancel(tc.DefaultContext())
go func() {
// Recover failure if exits
Expand All @@ -192,30 +198,37 @@ var _ = ginkgo.Describe("[HyperSDK Syncing]", func() {
// Give time for transactions to start processing
time.Sleep(5 * time.Second)

syncConcurrentNode := bootstrapNewHyperNode(tc)
syncConcurrentNode := e2e.CheckBootstrapIsPossible(tc, e2e.GetEnv(tc).GetNetwork())
syncConcurrentNodeURI := formatURI(syncConcurrentNode.URI, blockchainID)
uris = append(uris, syncConcurrentNodeURI)
c := rpc.NewJSONRPCClient(syncConcurrentNodeURI)
_, _, _, err := c.Network(ctx)
require.NoError(err)
cancel()
})
ginkgo.It("Accept a transaction after syncing", func() {
ginkgo.By("Accept a transaction after syncing", func() {
txWorkload, err := txWorkloadFactory.NewSizedTxWorkload(uris[0], 1)
require.NoError(err)
workload.ExecuteWorkload(tc.DefaultContext(), require, uris, txWorkload)
})
})

func getE2EURIs(tc tests.TestContext) []string {
return utils.Map(func(nodeURI tmpnet.NodeURI) string { return nodeURI.URI }, e2e.GetEnv(tc).GetNetwork().GetNodeURIs())
func getE2EURIs(tc tests.TestContext, blockchainID ids.ID) []string {
nodeURIs := e2e.GetEnv(tc).GetNetwork().GetNodeURIs()
uris := make([]string, 0, len(nodeURIs))
for _, nodeURI := range nodeURIs {
uris = append(uris, formatURI(nodeURI.URI, blockchainID))
}
return uris
}

func bootstrapNewHyperNode(tc tests.TestContext) *tmpnet.Node {
// TODO: return the node from CheckBoostrapIsPossible after https://github.com/ava-labs/avalanchego/pull/3253
e2e.CheckBootstrapIsPossible(tc, e2e.GetEnv(tc).GetNetwork())
var t *tmpnet.Node
return t
func getE2EBaseURIs(tc tests.TestContext) []string {
nodeURIs := e2e.GetEnv(tc).GetNetwork().GetNodeURIs()
uris := make([]string, 0, len(nodeURIs))
for _, nodeURI := range nodeURIs {
uris = append(uris, nodeURI.URI)
}
return uris
}

func formatURI(baseURI string, blockchainID ids.ID) string {
Expand Down
15 changes: 6 additions & 9 deletions tests/workload/apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,23 @@ import (
"github.com/stretchr/testify/require"

"github.com/ava-labs/hypersdk/rpc"
"github.com/ava-labs/hypersdk/utils"
)

func Ping(ctx context.Context, require *require.Assertions, uris []string) {
clients := utils.Map(rpc.NewJSONRPCClient, uris)

utils.ForEach(func(client *rpc.JSONRPCClient) {
for _, uri := range uris {
client := rpc.NewJSONRPCClient(uri)
ok, err := client.Ping(ctx)
require.NoError(err)
require.True(ok)
}, clients)
}
}

func GetNetwork(ctx context.Context, require *require.Assertions, uris []string, expectedNetworkID uint32, expectedChainID ids.ID) {
clients := utils.Map(rpc.NewJSONRPCClient, uris)

utils.ForEach(func(client *rpc.JSONRPCClient) {
for _, uri := range uris {
client := rpc.NewJSONRPCClient(uri)
networkID, _, chainID, err := client.Network(ctx)
require.NoError(err)
require.Equal(expectedNetworkID, networkID)
require.Equal(expectedChainID, chainID)
}, clients)
}
}
Loading