-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from Bidon15/tc-002
feat: remove redundant app code-base from 2 test-cases
- Loading branch information
Showing
10 changed files
with
218 additions
and
382 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package appsync | ||
|
||
import ( | ||
"context" | ||
"net" | ||
"time" | ||
|
||
"github.com/celestiaorg/test-infra/testkit/appkit" | ||
"github.com/celestiaorg/test-infra/tests/common" | ||
|
||
"github.com/testground/sdk-go/network" | ||
"github.com/testground/sdk-go/run" | ||
"github.com/testground/sdk-go/runtime" | ||
) | ||
|
||
func RunValidator(runenv *runtime.RunEnv, initCtx *run.InitContext) error { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute*4) | ||
defer cancel() | ||
|
||
syncclient := initCtx.SyncClient | ||
netclient := network.NewClient(syncclient, runenv) | ||
|
||
netclient.MustWaitNetworkInitialized(ctx) | ||
|
||
config := network.Config{ | ||
Network: "default", | ||
Enable: true, | ||
Default: network.LinkShape{ | ||
Bandwidth: 5 << 26, // 320Mib | ||
}, | ||
CallbackState: "network-configured", | ||
RoutingPolicy: network.AllowAll, | ||
} | ||
|
||
config.IPv4 = runenv.TestSubnet | ||
|
||
// using the assigned `GlobalSequencer` id per each of instance | ||
// to fill in the last 2 octects of the new IP address for the instance | ||
ipC := byte((initCtx.GlobalSeq >> 8) + 1) | ||
ipD := byte(initCtx.GlobalSeq) | ||
config.IPv4.IP = append(config.IPv4.IP[0:2:2], ipC, ipD) | ||
|
||
err := netclient.ConfigureNetwork(ctx, &config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
appcmd, err := common.BuildValidator(ctx, runenv, initCtx) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
runenv.RecordMessage("starting........") | ||
go appcmd.StartNode("info") | ||
|
||
// // wait for a new block to be produced | ||
time.Sleep(1 * time.Minute) | ||
|
||
// If all 3 validators submit pfd - it will take too long to produce a new block | ||
for i := 0; i < 10; i++ { | ||
runenv.RecordMessage("Submitting PFD with 90k bytes random data") | ||
err = appcmd.PayForData( | ||
appcmd.AccountAddress, | ||
50000, | ||
"test", | ||
appcmd.GetHomePath(), | ||
) | ||
if err != nil { | ||
runenv.RecordFailure(err) | ||
return err | ||
} | ||
|
||
s, err := appkit.GetLatestsBlockSize(net.ParseIP("127.0.0.1")) | ||
if err != nil { | ||
runenv.RecordMessage("err in last size call, %s", err.Error()) | ||
} | ||
|
||
runenv.RecordMessage("latest size on iteration %d of the block is - %d", i, s) | ||
} | ||
|
||
time.Sleep(30 * time.Second) | ||
runenv.RecordSuccess() | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Package common is a helper around redundant creation of App or Node part | ||
In order to eliminate the boilerplate code of creating a validators' set, | ||
please use `common.BuildValidator`. This Func does: | ||
- InitChain | ||
- Add-Gen-Account | ||
- Collect-GenTxs | ||
- Add-Persistent-Peers | ||
In addition, the func returns initialized cobra cmd, so you can continue | ||
operating with the validator | ||
appcmd, err := common.BuildValidator(ctx, runenv, initCtx) | ||
appcmd.PayForData(...) | ||
*/ | ||
package common |
Oops, something went wrong.