Skip to content

Commit

Permalink
feat: working example of checking balances
Browse files Browse the repository at this point in the history
  • Loading branch information
Bidon15 committed Feb 8, 2023
1 parent 6465619 commit e659226
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@ COPY --from=builder /testground_dep_list /
COPY --from=builder ${PLAN_DIR}/testplan.bin /testplan


EXPOSE 9090 26657 26656 1317 26658 26660
EXPOSE 9090 26657 26656 1317 26658 26660 26659
ENTRYPOINT [ "/testplan"]
10 changes: 5 additions & 5 deletions compositions/cluster-k8s/pfd-400.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
validator = "100"
bridge = "100"
light = "100"
submit-times = "12"
submit-times = "3"

[[groups]]
id = "seeds"
builder = "docker:generic"
[groups.resources]
memory = "4Gi"
cpu = "3"
memory = "2Gi"
cpu = "2"
[groups.instances]
count = 5
percentage = 0.0
Expand Down Expand Up @@ -85,7 +85,7 @@
artifact = ""
[groups.run.test_params]
bandwidth = "320Mib"
block-height = "40"
block-height = "20"
latency = "0"
role = "bridge"

Expand All @@ -108,6 +108,6 @@
artifact = ""
[groups.run.test_params]
bandwidth = "100Mib"
block-height = "20"
block-height = "16"
latency = "0"
role = "light"
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/celestiaorg/test-infra
go 1.19

replace (
github.com/celestiaorg/celestia-node => github.com/derrandz/celestia-node v0.7.0-rc1-blackbox-metrics
github.com/celestiaorg/utils => github.com/celestiaorg/utils v0.0.0-20230111201732-2d8b5f8774ad // uses an unmerged PR, delete when celestiaorg/utils PR#5 is merged
github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.8.0-sdk-v0.46.7
github.com/filecoin-project/dagstore => github.com/celestiaorg/dagstore v0.0.0-20221014072825-395797efb659
Expand All @@ -25,7 +24,9 @@ require (

require (
cosmossdk.io/math v1.0.0-beta.3
github.com/celestiaorg/celestia-node v0.6.2
//please use replace directive to use a local version of celestia-node
//until we get sealing merged in upcoming releases
github.com/celestiaorg/celestia-node v0.7.0-rc1
github.com/celestiaorg/nmt v0.14.0
github.com/libp2p/go-libp2p v0.24.1
github.com/tendermint/tendermint v0.35.4
Expand Down Expand Up @@ -59,7 +60,6 @@ require (
github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 // indirect
github.com/celestiaorg/quantum-gravity-bridge v1.3.0 // indirect
github.com/celestiaorg/rsmt2d v0.8.0 // indirect
github.com/celestiaorg/utils v0.0.0-00010101000000-000000000000 // indirect
github.com/cenkalti/backoff/v4 v4.2.0 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ github.com/celestiaorg/celestia-app v0.12.0-rc6 h1:MQ1Nb+awcnqK+EHpsH+NlBLT6F5Mp
github.com/celestiaorg/celestia-app v0.12.0-rc6/go.mod h1:4qMJfFq0Yr9At8dpP271seswj1wav20vqNfrnBlFxmo=
github.com/celestiaorg/celestia-core v1.14.0-tm-v0.34.23 h1:8zE523TUe5W33/nheJ9umHF2d1q6iHQlqJfMXMTPe3k=
github.com/celestiaorg/celestia-core v1.14.0-tm-v0.34.23/go.mod h1:fGDSg7aw2OH/Uze1zymop0x0y1kAPEO9OII2A2cb99Q=
github.com/celestiaorg/celestia-node v0.7.0-rc1 h1:jpCXPD5tWpsc9XbEPzA4IsZmNnVmNl1s26c1toCoLus=
github.com/celestiaorg/celestia-node v0.7.0-rc1/go.mod h1:wsYzebFMNG/Vw3wmc3Pvgezfkw6c6pZ2EITdZ63w3+0=
github.com/celestiaorg/cosmos-sdk v1.8.0-sdk-v0.46.7 h1:EADZy33ufskVIy6Rj6jbi3SOVCeYYo26zUi7iYx+QR0=
github.com/celestiaorg/cosmos-sdk v1.8.0-sdk-v0.46.7/go.mod h1:vg3Eza9adJJ5Mdx6boz5MpZsZcTZyrfTVYZHyi2zLm4=
github.com/celestiaorg/dagstore v0.0.0-20221014072825-395797efb659 h1:f3205vw3GYBtMiNoS+qB6IuHSs50Iwqsm9lNIikLTCk=
Expand All @@ -228,8 +230,6 @@ github.com/celestiaorg/quantum-gravity-bridge v1.3.0 h1:9zPIp7w1FWfkPnn16y3S4FpF
github.com/celestiaorg/quantum-gravity-bridge v1.3.0/go.mod h1:6WOajINTDEUXpSj5UZzod16UZ96ZVB/rFNKyM+Mt1gI=
github.com/celestiaorg/rsmt2d v0.8.0 h1:ZUxTCELZCM9zMGKNF3cT+rUqMddXMeiuyleSJPZ3Wn4=
github.com/celestiaorg/rsmt2d v0.8.0/go.mod h1:hhlsTi6G3+X5jOP/8Lb/d7i5y2XNFmnyMddYbFSmrgo=
github.com/celestiaorg/utils v0.0.0-20230111201732-2d8b5f8774ad h1:DHLh9QR6vWe47XsNFw5HNoKYXZBcrMgQtEDeoFo2dtY=
github.com/celestiaorg/utils v0.0.0-20230111201732-2d8b5f8774ad/go.mod h1:vQTh7MHnvpIeCQZ2/Ph+w7K1R2UerDheZbgJEJD2hSU=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw=
Expand Down Expand Up @@ -364,8 +364,6 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2U
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
github.com/derrandz/celestia-node v0.7.0-rc1-blackbox-metrics h1:EllRxOKC7fXNO7Js8hOmdxxYHfO3JehBCRrQ+P+Rwp0=
github.com/derrandz/celestia-node v0.7.0-rc1-blackbox-metrics/go.mod h1:JIg6wsZ/W2lZv22zfv5PkdOOFsu4bEBVlrPdIHWJjfM=
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I=
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE=
github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ=
Expand Down
1 change: 0 additions & 1 deletion testkit/appkit/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func (ak *AppKit) SignGenTx(accName, amount, krbackend, krpath string) (string,
"gentx",
accName,
amount,
ak.AccountAddress,
wrapFlag(flags.FlagEVMAddress),
ethAddress.String(),
wrapFlag(flags.FlagKeyringBackend),
Expand Down
14 changes: 14 additions & 0 deletions tests/helpers/common/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/celestiaorg/celestia-app/pkg/appconsts"
"github.com/celestiaorg/celestia-node/header"
"github.com/celestiaorg/celestia-node/nodebuilder"
"github.com/celestiaorg/celestia-node/state"
"github.com/celestiaorg/nmt/namespace"
tmrand "github.com/tendermint/tendermint/libs/rand"
"github.com/testground/sdk-go/runtime"
Expand Down Expand Up @@ -99,3 +100,16 @@ func VerifyDataInNamespace(ctx context.Context, nd *nodebuilder.Node, nid namesp
}
return nil
}

// CheckBalanceDeduction checks if the balance of a node has been deducted after a successful pfb
func CheckBalanceDeduction(ctx context.Context, nd *nodebuilder.Node, bal *state.Balance) error {
latestbal, err := nd.StateServ.Balance(ctx)
if err != nil {
return err
}

if latestbal.IsGTE(*bal) {
return fmt.Errorf("no balance deducted from the %s node", nd.Type.String())
}
return nil
}
7 changes: 5 additions & 2 deletions tests/helpers/fund-accs/run_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ func RunBridgeNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error {
runenv.RecordFailure(fmt.Errorf("bridge node is still syncing the past"))
}

// TODO(@Bidon15): Check in the cluster if we can reproduce this issue
// https://github.com/celestiaorg/celestia-node/issues/1219
bal, err := nd.StateServ.Balance(ctx)
if err != nil {
return err
Expand All @@ -118,6 +116,11 @@ func RunBridgeNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error {
}
}

err = common.CheckBalanceDeduction(ctx, nd, bal)
if err != nil {
return err
}

err = nd.Stop(ctx)
if err != nil {
return err
Expand Down
5 changes: 5 additions & 0 deletions tests/helpers/fund-accs/run_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ func RunFullNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error {
}
}

err = common.CheckBalanceDeduction(ctx, nd, bal)
if err != nil {
return err
}

err = nd.Stop(ctx)
if err != nil {
return err
Expand Down
6 changes: 6 additions & 0 deletions tests/helpers/fund-accs/run_light.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ func RunLightNode(runenv *runtime.RunEnv, initCtx *run.InitContext) error {
}
}

err = common.CheckBalanceDeduction(ctx, nd, bal)
if err != nil {
return err
}

err = nd.Stop(ctx)
if err != nil {
return err
}

_, err = syncclient.SignalEntry(ctx, testkit.FinishState)
if err != nil {
return err
Expand Down

0 comments on commit e659226

Please sign in to comment.