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

Add misbehaviour monitoring tests #485

Merged
merged 24 commits into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ba45cda
Refactor tests to use deterministic seed
akhilkumarpilli Apr 1, 2021
f57e6c7
Update docker files
akhilkumarpilli Apr 1, 2021
a45f641
Add misbehaviour monitor tests and address few comments
akhilkumarpilli Apr 2, 2021
0d044fd
Fix lint issues
akhilkumarpilli Apr 2, 2021
4c9573d
Modify gaia dockerfile
akhilkumarpilli Apr 2, 2021
1b027e9
Fix docker run issue
akhilkumarpilli Apr 2, 2021
58125d7
Modify misbehaviour test
akhilkumarpilli Apr 2, 2021
2c7ab07
Modify akash tests
akhilkumarpilli Apr 2, 2021
f218c86
Revert akash docker file changes
akhilkumarpilli Apr 2, 2021
befc0e8
use mock PV
colin-axner Apr 8, 2021
5be9a23
Update trusted height in tests
akhilkumarpilli Apr 8, 2021
ef8b22d
Modify misbehaviour monitoring tests
akhilkumarpilli Apr 8, 2021
31c97b7
Update header height in tests
akhilkumarpilli Apr 8, 2021
b79daf6
Update params
akhilkumarpilli Apr 8, 2021
3703f53
Add log
akhilkumarpilli Apr 8, 2021
9bba88b
Update revision number
akhilkumarpilli Apr 8, 2021
cafde28
Modify trusted height
akhilkumarpilli Apr 8, 2021
926f9e1
Revert revision number change
akhilkumarpilli Apr 8, 2021
ea3ab85
fix chainID and validator set usage
colin-axner Apr 8, 2021
77deec9
Update response code check
akhilkumarpilli Apr 8, 2021
64a42f3
misbehaviour tests working :tada:
colin-axner Apr 8, 2021
c339494
Merge branch 'master' into akhil/misbehaviour-tests
colin-axner Apr 8, 2021
203189a
minor fix in tests
colin-axner Apr 8, 2021
4a9dcfe
Merge branch 'akhil/misbehaviour-tests' of github.com:cosmos/relayer …
colin-axner Apr 8, 2021
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ chain-code/
two-chains/ibc-*
two-chains/.relayer
two-chains/*.log
test/setup/valkeys/*.json
4 changes: 2 additions & 2 deletions test/relayer_akash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

var (
akashChains = []testChain{
{"ibc-0", gaiaTestConfig},
{"ibc-1", akashTestConfig},
{"ibc-0", 0, gaiaTestConfig},
{"ibc-1", 0, akashTestConfig},
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
}
)

Expand Down
7 changes: 5 additions & 2 deletions test/relayer_gaia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (

var (
gaiaChains = []testChain{
{"ibc-0", gaiaTestConfig},
{"ibc-1", gaiaTestConfig},
{"ibc-0", 0, gaiaTestConfig},
{"ibc-1", 0, gaiaTestConfig},
}
)

Expand Down Expand Up @@ -148,3 +148,6 @@ func TestGaiaReuseIdentifiers(t *testing.T) {
require.Equal(t, expectedSrc, src)
require.Equal(t, expectedDst, dst)
}

func TestGaiaMisbehaviourMonitoring(t *testing.T) {
}
7 changes: 6 additions & 1 deletion test/setup/Dockerfile.akashtest
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@ ENV PACKAGES curl make git libc-dev bash gcc linux-headers eudev-dev python3

USER root

# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apk add --no-cache $PACKAGES

COPY ./akash-setup.sh .

COPY ./valkeys ./setup/valkeys

EXPOSE 26657

ENTRYPOINT [ "./akash-setup.sh" ]
# NOTE: to run this image, docker run -d -p 26657:26657 ./single-node.sh {{chain_id}} {{genesis_account}}
# NOTE: to run this image, docker run -d -p 26657:26657 ./akash-setup.sh {{chain_id}} {{genesis_account}} {{seeds}} {{priv_validator_key_path}}
8 changes: 3 additions & 5 deletions test/setup/Dockerfile.gaiatest
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ USER root
# Install minimum necessary dependencies, build Cosmos SDK, remove packages
RUN apk add --no-cache $PACKAGES

USER gaia

WORKDIR /gaia
colin-axner marked this conversation as resolved.
Show resolved Hide resolved

COPY ./gaia-setup.sh .

COPY ./valkeys ./setup/valkeys

EXPOSE 26657

ENTRYPOINT [ "./gaia-setup.sh" ]
# NOTE: to run this image, docker run -d -p 26657:26657 ./single-node.sh {{chain_id}} {{genesis_account}}
# NOTE: to run this image, docker run -d -p 26657:26657 ./gaia-setup.sh {{chain_id}} {{genesis_account}} {{seeds}} {{priv_validator_key_path}}
15 changes: 14 additions & 1 deletion test/setup/akash-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -o errexit -o nounset

CHAINID=$1
GENACCT=$2
SEEDS=$3
PRIVPATH=$4

if [ -z "$1" ]; then
echo "Need to input chain id..."
Expand All @@ -15,12 +17,23 @@ if [ -z "$2" ]; then
exit 1
fi

if [ -z "$3" ]; then
echo "Need to input seeds of validator key..."
exit 1
fi

if [ -z "$4" ]; then
echo "Need to input path of priv_validator_key json file"
exit 1
fi

# Build genesis file incl account for passed address
coins="10000000000stake,100000000000samoleans"
akash init --chain-id $CHAINID $CHAINID
akash keys add validator --keyring-backend="test"
echo $SEEDS | akash keys add validator --keyring-backend="test" --recover
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
akash add-genesis-account $(akash keys show validator -a --keyring-backend="test") $coins
akash add-genesis-account $GENACCT $coins
cp $PRIVPATH ~/.akash/config/priv_validator_key.json
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
akash gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAINID
akash collect-gentxs

Expand Down
15 changes: 14 additions & 1 deletion test/setup/gaia-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -o errexit -o nounset

CHAINID=$1
GENACCT=$2
SEEDS=$3
PRIVPATH=$4

if [ -z "$1" ]; then
echo "Need to input chain id..."
Expand All @@ -15,12 +17,23 @@ if [ -z "$2" ]; then
exit 1
fi

if [ -z "$3" ]; then
echo "Need to input seeds of validator key..."
exit 1
fi

colin-axner marked this conversation as resolved.
Show resolved Hide resolved
if [ -z "$4" ]; then
echo "Need to input path of priv_validator_key json file"
exit 1
fi

# Build genesis file incl account for passed address
coins="10000000000stake,100000000000samoleans"
gaiad init --chain-id $CHAINID $CHAINID
gaiad keys add validator --keyring-backend="test"
echo $SEEDS | gaiad keys add validator --keyring-backend="test" --recover
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
gaiad add-genesis-account $(gaiad keys show validator -a --keyring-backend="test") $coins
gaiad add-genesis-account $GENACCT $coins
cp $PRIVPATH ~/.gaia/config/priv_validator_key.json
gaiad gentx validator 5000000000stake --keyring-backend="test" --chain-id $CHAINID
gaiad collect-gentxs

Expand Down
Empty file added test/setup/valkeys/.gitkeep
Empty file.
10 changes: 10 additions & 0 deletions test/test_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
ry "github.com/cosmos/relayer/relayer"
)

const (
// SEED1 is a mnenomic
SEED1 = "cake blossom buzz suspect image view round utility meat muffin humble club model latin similar glow draw useless kiwi snow laugh gossip roof public"
colin-axner marked this conversation as resolved.
Show resolved Hide resolved
// SEED2 is a mnemonic
SEED2 = "near little movie lady moon fuel abandon gasp click element muscle elbow taste indoor soft soccer like occur legend coin near random normal adapt"
)

var (
// GAIA BLOCK TIMEOUTS are located in the gaia setup script in the
// setup directory.
Expand All @@ -37,13 +44,16 @@ var (
accountPrefix: "akash",
trustingPeriod: "330h",
}

seeds = []string{SEED1, SEED2}
)

type (
// testChain represents the different configuration options for spinning up a test
// cosmos-sdk based blockchain
testChain struct {
chainID string
seed int
t testChainConfig
}

Expand Down
21 changes: 20 additions & 1 deletion test/test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import (
"github.com/stretchr/testify/require"

ry "github.com/cosmos/relayer/relayer"

tmed25519 "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/privval"
)

// spinUpTestChains is to be passed any number of test chains with given configuration options
Expand Down Expand Up @@ -46,6 +49,7 @@ func spinUpTestChains(t *testing.T, testChains ...testChain) ry.Chains {
c := newTestChain(t, tc)
chains[i] = c
wg.Add(1)
genPrivValKeyJSON(tc.seed)
go spinUpTestContainer(t, rchan, pool, c, dir, &wg, tc)
}

Expand Down Expand Up @@ -135,7 +139,12 @@ func spinUpTestContainer(t *testing.T, rchan chan<- *dockertest.Resource,
Repository: containerName, // Name must match Repository
Tag: "latest", // Must match docker default build tag
ExposedPorts: []string{tc.t.rpcPort, c.GetRPCPort()},
Cmd: []string{c.ChainID, c.MustGetAddress().String()},
Cmd: []string{
c.ChainID,
c.MustGetAddress().String(),
fmt.Sprintf("%q", seeds[tc.seed]),
getPrivValFileName(tc.seed),
},
PortBindings: map[dc.Port][]dc.PortBinding{
dc.Port(tc.t.rpcPort): {{HostPort: c.GetRPCPort()}},
},
Expand Down Expand Up @@ -207,3 +216,13 @@ func genTestPathAndSet(src, dst *ry.Chain, srcPort, dstPort string) (*ry.Path, e
dst.PathEnd = path.Dst
return path, nil
}

func genPrivValKeyJSON(seedNumber int) {
privKey := tmed25519.GenPrivKeyFromSecret([]byte(seeds[seedNumber]))
filePV := privval.NewFilePV(privKey, getPrivValFileName(seedNumber), "/")
filePV.Key.Save()
}

func getPrivValFileName(seedNumber int) string {
return fmt.Sprintf("./setup/valkeys/priv_val%d.json", seedNumber)
}