-
Notifications
You must be signed in to change notification settings - Fork 49
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 #2934 from 0chain/feature/ct-auth-crash-and-reward
Conductor test - authorizer node recovery
- Loading branch information
Showing
18 changed files
with
198 additions
and
406 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
42 changes: 42 additions & 0 deletions
42
code/go/0chain.net/conductor/config/cases/round_random_seed.go
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,42 @@ | ||
package cases | ||
|
||
import ( | ||
"0chain.net/conductor/cases" | ||
"github.com/mitchellh/mapstructure" | ||
) | ||
|
||
type ( | ||
// RoundRandomSeed represents TestCaseConfigurator implementation. | ||
RoundRandomSeed struct { | ||
RandomSeed int64 `json:"random_seed" yaml:"random_seed" mapstructure:"random_seed"` | ||
} | ||
) | ||
|
||
const ( | ||
RoundRandomSeedName = "round random seed" | ||
) | ||
|
||
var ( | ||
// Ensure RoundRandomSeed implements TestCaseConfigurator. | ||
_ TestCaseConfigurator = (*RoundRandomSeed)(nil) | ||
) | ||
|
||
// NewRoundRandomSeed creates initialised RoundRandomSeed. | ||
func NewRoundRandomSeed() *RoundRandomSeed { | ||
return &RoundRandomSeed{} | ||
} | ||
|
||
// TestCase implements TestCaseConfigurator interface. | ||
func (n *RoundRandomSeed) TestCase() cases.TestCase { | ||
return cases.NewRoundHasFinalized() | ||
} | ||
|
||
// Name implements TestCaseConfigurator interface. | ||
func (n *RoundRandomSeed) Name() string { | ||
return RoundRandomSeedName | ||
} | ||
|
||
// Decode implements MapDecoder interface. | ||
func (n *RoundRandomSeed) Decode(val interface{}) error { | ||
return mapstructure.Decode(val, n) | ||
} |
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
16 changes: 16 additions & 0 deletions
16
code/go/0chain.net/smartcontract/zcnsc/mint_integration_tests.go
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 @@ | ||
//go:build integration_tests | ||
// +build integration_tests | ||
|
||
package zcnsc | ||
|
||
import ( | ||
cstate "0chain.net/chaincore/chain/state" | ||
"0chain.net/chaincore/transaction" | ||
crpc "0chain.net/conductor/conductrpc" | ||
"github.com/0chain/common/core/logging" | ||
) | ||
|
||
func (zcn *ZCNSmartContract) Mint(trans *transaction.Transaction, inputData []byte, ctx cstate.StateContextI) (resp string, err error) { | ||
logging.Logger.Debug("mint from CT") | ||
return zcn.mint(trans, inputData, crpc.Client().State().RoundRandomSeed.RandomSeed, ctx) | ||
} |
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,13 @@ | ||
//go:build !integration_tests | ||
// +build !integration_tests | ||
|
||
package zcnsc | ||
|
||
import ( | ||
cstate "0chain.net/chaincore/chain/state" | ||
"0chain.net/chaincore/transaction" | ||
) | ||
|
||
func (zcn *ZCNSmartContract) Mint(trans *transaction.Transaction, inputData []byte, ctx cstate.StateContextI) (resp string, err error) { | ||
return zcn.mint(trans, inputData, ctx.GetBlock().GetRoundRandomSeed(), ctx) | ||
} |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
#!/bin/bash | ||
# burn zcn in 0chain network | ||
burn_zcn_output=$(./zwalletcli/zwallet bridge-burn-eth --amount 1 --wallet wallet.json) | ||
burn_zcn_output=$(./zwalletcli/zwallet bridge-burn-eth --amount 10000000000 --wallet wallet.json) | ||
|
||
tx=$(echo $burn_zcn_output | sed -n 's/.*burn \[OK\]: \(.*\)/\1/p') | ||
|
||
# get authorizers signatures | ||
./zwalletcli/zwallet bridge-mint-zcn --wallet wallet.json | ||
./zwalletcli/zwallet bridge-mint-zcn --burn-txn-hash $tx --wallet wallet.json |
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,3 @@ | ||
#!/bin/sh | ||
|
||
sed -i "s|ethereum_node_url:\ .*|ethereum_node_url: $1|" config/config.yaml |
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,67 @@ | ||
enable: | ||
- "Node Recovery" | ||
- "Client Operation" | ||
|
||
# sets of test cases | ||
sets: | ||
- name: "Node Recovery" | ||
tests: | ||
- "Authorizer Recovery - Authorizer should be able to sign tickets and gain rewards after it is recovered" | ||
|
||
tests: | ||
- name: "Authorizer Recovery - Authorizer should be able to sign tickets and gain rewards after it is recovered" | ||
flow: | ||
- set_monitor: "sharder-1" | ||
- cleanup_bc: {} | ||
- command: | ||
name: "cleanup_0dns" | ||
- start: ['sharder-1', 'sharder-2', 'miner-1', 'miner-2', 'miner-3', 'miner-4'] | ||
- wait_round: | ||
round: 15 # just wait the BC starts | ||
- start: ['0dns'] | ||
- sleep: "20s" | ||
- start: ['0box'] | ||
- sleep: "20s" | ||
- wait_round: | ||
shift: 50 | ||
- command: | ||
name: "register_authorizer" | ||
- wait_add: | ||
authorizers: ['authorizer-1','authorizer-2','authorizer-3','authorizer-4'] | ||
start: true | ||
- wait_round: | ||
shift: 200 | ||
- sync_latest_aggregates: | ||
authorizers: | ||
- "d5b9204835a6ea8ba93a0b4f14ce38bc72dec5165465416f0a3b9f66f988e1ab" | ||
required: true | ||
- round_random_seed: | ||
random_seed: 54 | ||
- command: | ||
name: "mint_zcn" | ||
- check_aggregate_value_change: | ||
provider_type: authorizer | ||
provider_id: d5b9204835a6ea8ba93a0b4f14ce38bc72dec5165465416f0a3b9f66f988e1ab | ||
key: total_rewards | ||
monotonicity: increase | ||
timeout: "2m" | ||
- stop: ['authorizer-4'] | ||
- wait_round: | ||
shift: 100 | ||
- wait_add: | ||
authorizers: [ 'authorizer-4' ] | ||
start: true | ||
- sync_latest_aggregates: | ||
authorizers: | ||
- "d5b9204835a6ea8ba93a0b4f14ce38bc72dec5165465416f0a3b9f66f988e1ab" | ||
required: true | ||
- round_random_seed: | ||
random_seed: 54 | ||
- command: | ||
name: "mint_zcn" | ||
- check_aggregate_value_change: | ||
provider_type: authorizer | ||
provider_id: d5b9204835a6ea8ba93a0b4f14ce38bc72dec5165465416f0a3b9f66f988e1ab | ||
key: total_rewards | ||
monotonicity: increase | ||
timeout: "2m" |
Oops, something went wrong.