Skip to content

Commit 9a0ec36

Browse files
committed
Set the test/integration directory to be the same as 92c5238 to ignore merge conflicts
1 parent ff412c5 commit 9a0ec36

21 files changed

+463
-260
lines changed

Diff for: test/integration/.env.ciExample

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# ------------
2+
# General
3+
# ------------
4+
CONSENSUS_THRESHOLD=10
5+
ETHEREUM_PRIVATE_KEY="c87509a1c067bbde78beb793e6fa76530b6382a4c0241e5e4a9ec0a0f44dc0d3"
6+
# ------------
7+
# Local
8+
# ------------
9+
LOCAL_PROVIDER="http://localhost:7545"
10+
# Local validator count must be at least 1 and no more than 8
11+
# ------------
12+
# Network
13+
# ------------
14+
# Owner of the bridgebank, this must be set when we are deploying to tesnet or mainnet
15+
OWNER='0x627306090abaB3A6e1400e9345bC60c78a8BEf57'
16+
# Replace example MNEMONIC with your MetaMask mnemonic
17+
MNEMONIC="candy maple cake sugar pudding cream honey rich smooth crumble sweet treat"
18+
# Replace example INFURA_PROJECT_ID with your Infura project's ID
19+
INFURA_PROJECT_ID="JFSH7439sjsdtqTM23Dz"
20+
# Replace example OPERATOR with your MetaMask address
21+
OPERATOR='0x627306090abaB3A6e1400e9345bC60c78a8BEf57'
22+
# Replace example INITIAL_VALIDATOR_ADDRESSES with the desired validator addresses
23+
INITIAL_VALIDATOR_ADDRESSES='0x627306090abaB3A6e1400e9345bC60c78a8BEf57'
24+
# Replace example INITIAL_VALIDATOR_POWERS with the desired validator powers
25+
INITIAL_VALIDATOR_POWERS="50"
26+
# On the mainnet, set the price of gas based on the current gas prices
27+
# This is not needed locally
28+
MAINNET_GAS_PRICE=10000000
29+
# If you are deploying a new instance of peggy that needs to use eRowan,
30+
# set this variable to the address of the eRowan smart contract
31+
EROWAN_ADDRESS='0x0d8cc4b8d15D4c3eF1d70af0071376fb26B5669b'

Diff for: test/integration/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
vagrantenv.sh

Diff for: test/integration/Dockerfile.testrunner

+12-9
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@ EXPOSE 26657
3232

3333
RUN apk add --update --no-cache $PACKAGES
3434

35-
# Copy the smart contract ABIs over.
36-
ADD cmd/ebrelayer/contract/generated /sif/cmd/ebrelayer/contract/generated
37-
38-
# Copy the compiled binaires over.
39-
COPY --from=build /go/bin/sifnoded /usr/bin/sifnoded
40-
COPY --from=build /go/bin/sifnodecli /usr/bin/sifnodecli
41-
COPY --from=build /go/bin/ebrelayer /usr/bin/ebrelayer
42-
4335
# extras for test suite
4436
RUN apk add python3 vim bash yarn npm socat busybox-extras
4537
RUN \
@@ -50,4 +42,15 @@ RUN \
5042
rm -rf /var/cache/apk/*
5143
RUN gem install rake
5244
RUN wget https://github.com/mikefarah/yq/releases/download/3.4.0/yq_linux_amd64 -O /usr/bin/yq &&\
53-
chmod +x /usr/bin/yq
45+
chmod +x /usr/bin/yq
46+
47+
# Copy the smart contract ABIs over.
48+
ADD cmd/ebrelayer/contract/generated /sif/cmd/ebrelayer/contract/generated
49+
50+
# Copy the compiled binaires over.
51+
COPY --from=build /go/bin/sifnoded /usr/bin/sifnoded
52+
COPY --from=build /go/bin/sifnodecli /usr/bin/sifnodecli
53+
COPY --from=build /go/bin/ebrelayer /usr/bin/ebrelayer
54+
55+
COPY $YARN_CACHE_DIR /yarncache
56+
RUN yarn config set cache-folder /yarncache

Diff for: test/integration/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44

55
The [setup-linux-environment.sh](./setup-linux-environment.sh) script will install all the tools you need to run in a fresh Linux environment (go, make, etc). This is the script that github actions use to set up that environment.
66

7-
## Execute in test environment
7+
## Execute in a local environment (not github actions)
88

99
Run `make` in test/integration/vagrant. That uses [vagrant](https://www.vagrantup.com/docs/installation) to set up a fresh Linux environment with all the tools necessary for building and running the tests. It will:
1010

11-
1. Create a new Linux machine (using virtualbox).
12-
2. Install the tools (using setup-linux-environment.sh)
13-
3. Run the tests.
14-
4. Leave a virtual machine running with the full test environment available for use.
11+
* Mount local files to the virtualbox instance
12+
* Create a new Linux machine (using virtualbox).
13+
* Install the tools (using setup-linux-environment.sh)
14+
* Run the tests.
15+
* Leave a virtual machine running with the full test environment available for use.
16+
* Copies logs to `data/*` and tars them up into `datafiles.12-11-16-15-53.tar`.
1517

1618
Running `make` again will run the tests again in the existing environment.
1719

Diff for: test/integration/docker-compose-integration.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,24 @@ services:
1818
MNEMONIC: ${MNEMONIC1}
1919
ETHEREUM_PRIVATE_KEY: ${ETHEREUM_PRIVATE_KEY1}
2020
RELAYER_ENABLED: "true"
21+
YARN_CACHE_DIR: ${YARN_CACHE_DIR}
2122
volumes:
2223
- ${BASEDIR}/deploy/networks/validators/${CHAINNET}/${MONIKER1}:/root:Z
2324
- ${BASEDIR}/scripts:/scripts
2425
- ${BASEDIR}/test:/test
2526
- ${BASEDIR}/deploy/networks/network-definition.yml:/network-definition.yml
2627
- ${BASEDIR}/smart-contracts:/smart-contracts
27-
entrypoint: /test/integration/integration-entrypoint.sh
28+
- ${BASEDIR}:/sifnode
29+
- yarncache:/yarncache
30+
31+
entrypoint: /test/integration/integration-entrypoint.sh ${ADD_VALIDATOR_TO_WHITELIST}
2832
networks:
2933
genesis_sifchain:
3034
ipv4_address: ${IPV4_ADDRESS1}
3135

3236
networks:
3337
genesis_sifchain:
34-
external: true
38+
external: true
39+
40+
volumes:
41+
yarncache:

Diff for: test/integration/get_eth_balance.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
addr=$1
4+
shift
5+
token=$1
6+
shift
7+
8+
docker exec -ti ${CONTAINER_NAME} bash -c "cd /smart-contracts; yarn peggy:getTokenBalance ${addr:=${BRIDGE_BANK_ADDRESS}} ${token:=eth}"

Diff for: test/integration/get_sif_balance.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
addr=$1
4+
shift
5+
6+
sifnodecli q auth account ${addr:=${OWNER_ADDR}} -o json | jq

Diff for: test/integration/initial_test_balances.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import time
2+
3+
from test_utilities import network_password, owner_addr, amount_in_wei, user1_addr, \
4+
sif_tx_send, transact_ethereum_currency_to_sifchain_addr, get_shell_output, wait_for_sif_account
5+
6+
7+
def setup_currencies():
8+
print(f"adding eth to {owner_addr}")
9+
transact_ethereum_currency_to_sifchain_addr(owner_addr, "eth", amount_in_wei(10))
10+
print(f"adding eth to {user1_addr}")
11+
transact_ethereum_currency_to_sifchain_addr(user1_addr, "eth", amount_in_wei(13))
12+
time.sleep(15)
13+
sif_tx_send(owner_addr, user1_addr, amount_in_wei(23), "rowan", network_password)
14+
15+
16+
setup_currencies()

Diff for: test/integration/integration-entrypoint.sh

+13-4
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@
55

66
set -x
77

8+
ADD_VALIDATOR_TO_WHITELIST=$1
9+
shift
10+
811
NETDEF=/network-definition.yml
912
PASSWORD=$(cat $NETDEF | yq r - ".password")
1013

11-
#
12-
# Daemon.
13-
#
14+
if [ -z "${ADD_VALIDATOR_TO_WHITELIST}" ]
15+
then
16+
# no whitelist validator requested; mostly useful for testing validator whitelisting
17+
echo $0: no whitelisted validators
18+
else
19+
whitelisted_validator=$(yes $PASSWORD | sifnodecli keys show -a --bech val $MONIKER)
20+
echo $0: whitelisted validator $whitelisted_validator
21+
sifnoded add-genesis-validators $whitelisted_validator
22+
fi
23+
1424
start_daemon() {
15-
sifnoded add-genesis-validators $(yes $PASSWORD | sifnodecli keys show -a --bech val $MONIKER)
1625
sifnoded start --rpc.laddr tcp://0.0.0.0:26657
1726
}
1827

Diff for: test/integration/monitor-bridgebank.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# usually run like this:
4+
# nohup bash /sifnode/test/integration/monitor-bridgebank.sh > /tmp/bridgebank.txt &
5+
6+
while true
7+
do
8+
date
9+
docker exec integration_sifnode1_1 bash -c "cd /smart-contracts && yarn peggy:getTokenBalance $BRIDGE_BANK_ADDRESS eth" >> /tmp/bridgebank.txt
10+
sleep 5
11+
done

Diff for: test/integration/no_whitelisted_validators.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from test_utilities import owner_addr, amount_in_wei, transact_ethereum_currency_to_sifchain_addr, print_error_message
2+
3+
4+
def no_whitelisted_validators():
5+
print(f"adding eth to {owner_addr}, expect to fail")
6+
try:
7+
transact_ethereum_currency_to_sifchain_addr(owner_addr, "eth", amount_in_wei(10))
8+
print("did not fail")
9+
transferred = True
10+
except:
11+
# this is the good path; we don't want the transfer to happen
12+
transferred = False
13+
print("did fail")
14+
if transferred:
15+
print_error_message("balance should not have tranferred, we should have no validators")
16+
17+
18+
no_whitelisted_validators()

Diff for: test/integration/peggy-basic-demo.sh

+18-18
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
## Case 1
44
## 1. send tx to cosmos after get the lock event in ethereum
55
sifnodecli tx ethbridge create-claim 0x30753E4A8aad7F8597332E813735Def5dD395028 3 eth 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 \
6-
$(sifnodecli keys show user2 -a) $(sifnodecli keys show user1 -a --bech val) 5 lock \
7-
--token-contract-address=0x0000000000000000000000000000000000000000 --ethereum-chain-id=3 --from=user1 --yes
6+
$(sifnodecli keys show akasha -a) $(sifnodecli keys show shadowfiend -a --bech val) 5 lock \
7+
--token-contract-address=0x0000000000000000000000000000000000000000 --ethereum-chain-id=3 --from=shadowfiend --yes
88

99
# 2. query the tx
1010
#sifnodecli q tx
1111

12-
# 3. check user2 account balance
13-
sifnodecli q auth account $(sifnodecli keys show user2 -a)
12+
# 3. check akasha account balance
13+
sifnodecli q auth account $(sifnodecli keys show akasha -a)
1414

1515
# 4. query the prophecy
1616
sifnodecli query ethbridge prophecy 0x30753E4A8aad7F8597332E813735Def5dD395028 3 eth 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 --ethereum-chain-id=3 --token-contract-address=0x0000000000000000000000000000000000000000
1717

1818
## Case 2
19-
## 1. burn peggyetch for user2
20-
sifnodecli tx ethbridge burn $(sifnodecli keys show user2 -a) 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 \
21-
1 ceth --ethereum-chain-id=3 --from=user2 --yes
19+
## 1. burn peggyetch for akasha
20+
sifnodecli tx ethbridge burn $(sifnodecli keys show akasha -a) 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 \
21+
1 ceth --ethereum-chain-id=3 --from=akasha --yes
2222

2323
## 2. query the tx
2424
#sifnodecli q tx
2525

26-
## 3. check user2 account balance
27-
sifnodecli q auth account $(sifnodecli keys show user2 -a)
26+
## 3. check akasha account balance
27+
sifnodecli q auth account $(sifnodecli keys show akasha -a)
2828

2929
## Case 3
30-
## 1. lock user2 rwn in sifchain
31-
sifnodecli tx ethbridge lock $(sifnodecli keys show user2 -a) 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 \
32-
10 rwn --ethereum-chain-id=3 --from=user2 --yes
30+
## 1. lock akasha rwn in sifchain
31+
sifnodecli tx ethbridge lock $(sifnodecli keys show akasha -a) 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 \
32+
10 rwn --ethereum-chain-id=3 --from=akasha --yes
3333

3434
## 2. query the tx
3535
#sifnodecli q tx
3636

37-
## 3. check user2 account balance
38-
sifnodecli q auth account $(sifnodecli keys show user2 -a)
37+
## 3. check akasha account balance
38+
sifnodecli q auth account $(sifnodecli keys show akasha -a)
3939

4040
## Case 4
4141
## 1. send tx to cosmos after peggyrwn burn in ethereum
4242
sifnodecli tx ethbridge create-claim 0x30753E4A8aad7F8597332E813735Def5dD395028 1 rwn 0x11111111262b236c9ac9a9a8c8e4276b5cf6b2c9 \
43-
$(sifnodecli keys show user2 -a) $(sifnodecli keys show user1 -a --bech val) \
44-
1 burn --ethereum-chain-id=3 --token-contract-address=0x345cA3e014Aaf5dcA488057592ee47305D9B3e10 --from=user1 --yes
43+
$(sifnodecli keys show akasha -a) $(sifnodecli keys show shadowfiend -a --bech val) \
44+
1 burn --ethereum-chain-id=3 --token-contract-address=0x345cA3e014Aaf5dcA488057592ee47305D9B3e10 --from=shadowfiend --yes
4545

4646
## 2. query the tx
4747
#sifnodecli q tx
4848

49-
## 3. check user2 account balance
50-
sifnodecli q auth account $(sifnodecli keys show user2 -a)
49+
## 3. check akasha account balance
50+
sifnodecli q auth account $(sifnodecli keys show akasha -a)

Diff for: test/integration/peggy-basic-test-docker.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ def test_case_1():
103103

104104
def test_case_2():
105105
print(
106-
"########## Test Case Two Start: burn ceth in sifchain then eth back to ethereum"
106+
"########## Test Case Two Start: burn ceth in sifchain"
107107
)
108108
balance_before_tx = int(get_sifchain_balance(USER, PEGGYETH, network_password))
109109
print('before_tx', balance_before_tx)
110110
print("Before burn transaction {}'s balance of {} is {}".format(
111111
USER, PEGGYETH, balance_before_tx))
112-
amount = amount_in_wei(7)
112+
amount = amount_in_wei(1)
113113
if balance_before_tx < amount:
114114
print_error_message("No enough ceth to burn")
115115
return

Diff for: test/integration/peggy-basic-test.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import time
44

55
# define users
6-
VALIDATOR = "user1"
7-
USER = "user2"
6+
VALIDATOR = "shadowfiend"
7+
USER = "akasha"
88
ROWAN = "rwn"
99
PEGGYETH = "ceth"
1010
PEGGYROWAN = "erwn"

0 commit comments

Comments
 (0)