Skip to content

Commit

Permalink
Fix integration test driver #167 (#166)
Browse files Browse the repository at this point in the history
* go mod replace

* main use fatalf log

* Apply changes from 1e2ad61

* go mod, actions

Co-authored-by: Daniel <danwtisdall@gmail.com>
  • Loading branch information
danwt and Daniel authored Jun 29, 2022
1 parent a5c7330 commit deee1da
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 24 deletions.
40 changes: 28 additions & 12 deletions integration-tests/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s System) sendTokens(
verbose bool,
) {
binaryName := s.chainConfigs[action.chain].binaryName
bz, err := exec.Command("docker", "exec", s.containerConfig.instanceName, binaryName,
cmd := exec.Command("docker", "exec", s.containerConfig.instanceName, binaryName,

"tx", "bank", "send",
s.validatorConfigs[action.from].delAddress,
Expand All @@ -39,7 +39,11 @@ func (s System) sendTokens(
`--keyring-backend`, `test`,
`-b`, `block`,
`-y`,
).CombinedOutput()
)
if verbose {
fmt.Println("sendTokens cmd:", cmd.String())
}
bz, err := cmd.CombinedOutput()

if err != nil {
log.Fatal(err, "\n", string(bz))
Expand Down Expand Up @@ -290,14 +294,20 @@ func (s System) startConsumerChain(
action StartConsumerChainAction,
verbose bool,
) {
bz, err := exec.Command("docker", "exec", s.containerConfig.instanceName, s.chainConfigs[action.consumerChain].binaryName,
cmd := exec.Command("docker", "exec", s.containerConfig.instanceName, s.chainConfigs[action.providerChain].binaryName,

"query", "provider", "consumer-genesis",
s.chainConfigs[action.consumerChain].chainId,

`--node`, s.getValidatorNode(action.providerChain, s.getValidatorNum(action.providerChain)),
`-o`, `json`,
).CombinedOutput()
)

if verbose {
log.Println("startConsumerChain cmd: ", cmd.String())
}

bz, err := cmd.CombinedOutput()

if err != nil {
log.Fatal(err, "\n", string(bz))
Expand Down Expand Up @@ -438,18 +448,20 @@ func (s System) addIbcChannel(
action AddIbcChannelAction,
verbose bool,
) {
// // hermes create channel ibc-1 ibc-2 --port-a transfer --port-b transfer -o unordered
cmd := exec.Command("docker", "exec", s.containerConfig.instanceName, "/root/.cargo/bin/hermes",
"create", "channel",
s.chainConfigs[action.chainA].chainId,
"--order", action.order,
"--channel-version", s.containerConfig.ccvVersion,
"--connection-a", "connection-"+fmt.Sprint(action.connectionA),
"--port-a", action.portA,
"--port-b", action.portB,
"-o", action.order,
"--channel-version", s.containerConfig.ccvVersion,
// "--connection-a",
"connection-"+fmt.Sprint(action.connectionA),
s.chainConfigs[action.chainA].chainId,
)

if verbose {
fmt.Println("addIbcChannel cmd:", cmd.String())
}

cmdReader, err := cmd.StdoutPipe()
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -487,9 +499,13 @@ func (s System) relayPackets(
verbose bool,
) {
// hermes clear packets ibc0 transfer channel-13
bz, err := exec.Command("docker", "exec", s.containerConfig.instanceName, "/root/.cargo/bin/hermes", "clear", "packets",
cmd := exec.Command("docker", "exec", s.containerConfig.instanceName, "/root/.cargo/bin/hermes", "clear", "packets",
s.chainConfigs[action.chain].chainId, action.port, "channel-"+fmt.Sprint(action.channel),
).CombinedOutput()
)
if verbose {
log.Println("relayPackets cmd:", cmd.String())
}
bz, err := cmd.CombinedOutput()

if err != nil {
log.Fatal(err, "\n", string(bz))
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s System) runStep(step Step, verbose bool) {
case DelegateTokensAction:
s.delegateTokens(action, verbose)
default:
log.Fatal(fmt.Sprintf(`unknown action: %#v`, action))
log.Fatalf(fmt.Sprintf(`unknown action: %#v`, action))
}

modelState := step.state
Expand Down
24 changes: 13 additions & 11 deletions integration-tests/testnet-scripts/start-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,19 @@ do
fi

# Make a gentx (this command also sets up validator state on disk even if we are not going to use the gentx for anything)
STAKE_AMOUNT=$(echo "$VALIDATORS" | jq -r ".[$i].stake")
$BIN gentx validator$VAL_ID "$STAKE_AMOUNT" \
--home /$CHAIN_ID/validator$VAL_ID \
--keyring-backend test \
--moniker validator$VAL_ID \
--chain-id=$CHAIN_ID

# Copy gentxs to the first validator for possible future collection.
# Obviously we don't need to copy the first validator's gentx to itself
if [ $VAL_ID != $FIRST_VAL_ID ]; then
cp /$CHAIN_ID/validator$VAL_ID/config/gentx/* /$CHAIN_ID/validator$FIRST_VAL_ID/config/gentx/
if [ "$SKIP_GENTX" = "false" ] ; then
STAKE_AMOUNT=$(echo "$VALIDATORS" | jq -r ".[$i].stake")
$BIN gentx validator$VAL_ID "$STAKE_AMOUNT" \
--home /$CHAIN_ID/validator$VAL_ID \
--keyring-backend test \
--moniker validator$VAL_ID \
--chain-id=$CHAIN_ID

# Copy gentxs to the first validator for possible future collection.
# Obviously we don't need to copy the first validator's gentx to itself
if [ $VAL_ID != $FIRST_VAL_ID ]; then
cp /$CHAIN_ID/validator$VAL_ID/config/gentx/* /$CHAIN_ID/validator$FIRST_VAL_ID/config/gentx/
fi
fi

# Modify tendermint configs of validator
Expand Down

0 comments on commit deee1da

Please sign in to comment.