Skip to content

Commit

Permalink
eth/harness: Work with v1.10.21.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeGruffins authored and chappjc committed Aug 19, 2022
1 parent 07a74fa commit 1acf1cf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
21 changes: 14 additions & 7 deletions client/asset/eth/nodeclient_harness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ func runSimnet(m *testing.M) (int, error) {
fmt.Printf("Token swap contract addr is %v\n", token.SwapContracts[0].Address)
fmt.Printf("Test token contract addr is %v\n", token.Address)

ethSwapContractAddr = dexeth.ContractAddresses[0][dex.Simnet]

err = setupWallet(simnetWalletDir, simnetWalletSeed, "localhost:30355", dex.Simnet)
if err != nil {
return 1, err
Expand Down Expand Up @@ -969,13 +971,13 @@ func testInitiate(t *testing.T, assetID uint32) {

isETH := assetID == BipID

c := simnetContractor
sc := simnetContractor
balance := func() (*big.Int, error) {
return ethClient.addressBalance(ctx, simnetAddr)
}
gases := ethGases
if !isETH {
c = simnetTokenContractor
sc = simnetTokenContractor
balance = func() (*big.Int, error) {
return simnetTokenContractor.balance(ctx)
}
Expand All @@ -988,7 +990,7 @@ func testInitiate(t *testing.T, assetID uint32) {
secretHashes := make([][32]byte, numSecretHashes)
for i := 0; i < numSecretHashes; i++ {
copy(secretHashes[i][:], encode.RandomBytes(32))
swap, err := c.swap(ctx, secretHashes[i])
swap, err := sc.swap(ctx, secretHashes[i])
if err != nil {
t.Fatal("unable to get swap state")
}
Expand Down Expand Up @@ -1076,7 +1078,7 @@ func testInitiate(t *testing.T, assetID uint32) {
var totalVal uint64
originalStates := make(map[string]dexeth.SwapStep)
for _, tSwap := range test.swaps {
swap, err := c.swap(ctx, bytesToArray(tSwap.SecretHash))
swap, err := sc.swap(ctx, bytesToArray(tSwap.SecretHash))
if err != nil {
t.Fatalf("%s: swap error: %v", test.name, err)
}
Expand All @@ -1101,9 +1103,14 @@ func testInitiate(t *testing.T, assetID uint32) {
txOpts, _ := ethClient.txOpts(ctx, optsVal, expGas, dexeth.GweiToWei(maxFeeRate))
var tx *types.Transaction
if test.overflow {
tx, err = initiateOverflow(c.(*contractorV0), txOpts, test.swaps)
switch c := sc.(type) {
case *contractorV0:
tx, err = initiateOverflow(c, txOpts, test.swaps)
case *tokenContractorV0:
tx, err = initiateOverflow(c.contractorV0, txOpts, test.swaps)
}
} else {
tx, err = c.initiate(txOpts, test.swaps)
tx, err = sc.initiate(txOpts, test.swaps)
}
if err != nil {
if test.swapErr {
Expand Down Expand Up @@ -1168,7 +1175,7 @@ func testInitiate(t *testing.T, assetID uint32) {
}

for _, tSwap := range test.swaps {
swap, err := c.swap(ctx, bytesToArray(tSwap.SecretHash))
swap, err := sc.swap(ctx, bytesToArray(tSwap.SecretHash))
if err != nil {
t.Fatalf("%s: swap error post-init: %v", test.name, err)
}
Expand Down
2 changes: 1 addition & 1 deletion dex/testing/eth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sandboxed environment for testing dex swap transactions.
## Dependencies

The harness depends on [geth](https://github.com/ethereum/go-ethereum/tree/master/cmd/geth)
to run.
to run. geth v1.10.21+ is recommended.

It also requires tmux and bc.

Expand Down
2 changes: 2 additions & 0 deletions dex/testing/eth/create-node.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ADDRESS_JSON=$8
ADDRESS_JSON_FILE_NAME=$9
NODE_KEY=${10}
SYNC_MODE=${11}
AUTHRPC_PORT=${12}

GROUP_DIR="${NODES_ROOT}/${NAME}"
MINE_JS="${GROUP_DIR}/mine.js"
Expand Down Expand Up @@ -73,6 +74,7 @@ DatasetDir = "${NODE_DIR}/.ethash"
[Node]
DataDir = "${NODE_DIR}"
AuthPort = ${AUTHRPC_PORT}
[Node.P2P]
NoDiscovery = true
Expand Down
18 changes: 13 additions & 5 deletions dex/testing/eth/harness.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,31 @@ ALPHA_ADDRESS_JSON='{"address":"18d65fb8d60c1199bb1ad381be47aa692b482605","crypt
ALPHA_NODE_KEY="71d810d39333296b518c846a3e49eca55f998fd7994998bb3e5048567f2f073c"
ALPHA_ENODE="897c84f6e4f18195413c1d02927e6a4093f5e7574b52bdec6f20844c4f1f6dd3f16036a9e600bd8681ab50fd8dd144df4a6ba9dd8722bb578a86aaa8222c964f"
ALPHA_NODE_PORT="30304"
ALPHA_AUTHRPC_PORT="8552"

# BETA_ADDRESS="4f8ef3892b65ed7fc356ff473a2ef2ae5ec27a06"
BETA_ADDRESS_JSON_FILE_NAME="UTC--2021-01-27T08-20-58.179642501Z--4f8ef3892b65ed7fc356ff473a2ef2ae5ec27a06"
BETA_ADDRESS_JSON='{"address":"4f8ef3892b65ed7fc356ff473a2ef2ae5ec27a06","crypto":{"cipher":"aes-128-ctr","ciphertext":"c5672bb829df9e209ca8ce18dbdd1fed69c603d639e06ab09127b672a609c121","cipherparams":{"iv":"24460eb2934c8b61cee3ad0aa7b843c0"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"1f85da881994ca7b4a23f0698da70500a4b79f97a4450b83b129ebf3b4c28f50"},"mac":"1ecea707f1bffa1f6f944cb47e83118d8179e8a5005b83c88610b7e8692a1197"},"id":"56633762-6fb1-4cbf-8396-3a2e4661f7d4","version":3}'
BETA_NODE_KEY="0f3f23a0f14202da009bd59a96457098acea901986629e54d5be1eea32fc404a"
BETA_ENODE="b1d3e358ee5c9b268e911f2cab47bc12d0e65c80a6d2b453fece34facc9ac3caed14aa3bc7578166bb08c5bc9719e5a2267ae14e0b42da393f4d86f6d5829061"
BETA_NODE_PORT="30305"
BETA_AUTHRPC_PORT="8553"

GAMMA_ADDRESS="41293c2032bac60aa747374e966f79f575d42379"
GAMMA_ADDRESS_JSON_FILE_NAME="UTC--2021-03-01T02-12-42.714340074Z--41293c2032bac60aa747374e966f79f575d42379"
GAMMA_ADDRESS_JSON='{"address":"41293c2032bac60aa747374e966f79f575d42379","crypto":{"cipher":"aes-128-ctr","ciphertext":"5191719067513511b07d959de1a86cd37c3f7011dce75f62c791114c3a62b15b","cipherparams":{"iv":"cdfcd9e475f2af7df08a8a36cc0de976"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"5630591da82b8517f1b8f61719fbb552e41f25861cc20bc4671a11a47b427d31"},"mac":"d13259851d78deb70d1273ab151d4a12583b94f5cbdf31d86f02bb549d241d36"},"id":"235ba177-e32c-4d23-8d94-a57bc04b97ca","version":3}'
GAMMA_NODE_KEY="9e102b8ba8cad4c6b9db6c881915d3f1bb206e76113266bf48266de0474844fd"
GAMMA_ENODE="b1c14deee09b9d5549c90b7b30a35c812a56bf6afea5873b05d7a1bcd79c7b0848bcfa982faf80cc9e758a3a0d9b470f0a002840d365050fd5bf45052a6ec313"
GAMMA_NODE_PORT="30306"
GAMMA_AUTHRPC_PORT="8554"

DELTA_ADDRESS="d12ab7cf72ccf1f3882ec99ddc53cd415635c3be"
DELTA_ADDRESS_JSON_FILE_NAME="UTC--2021-03-01T02-31-13.365402148Z--d12ab7cf72ccf1f3882ec99ddc53cd415635c3be"
DELTA_ADDRESS_JSON='{"address":"d12ab7cf72ccf1f3882ec99ddc53cd415635c3be","crypto":{"cipher":"aes-128-ctr","ciphertext":"a0e9a3da5d0c88c922b5d7e817693552fe17dfd4c598e2a8b08ee53a706a8ffc","cipherparams":{"iv":"28b0a443403b7a02001f07a35724f6e6"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"f790f584bf396cacc06f28201aa697825011e84f570759d6108e20c5ee4fffce"},"mac":"529318e5eec2474221912d01e5a534a0b1dbfb19499ffaf942be6375611caa83"},"id":"d8670e33-8094-45b7-9386-d936e6bf4c1b","version":3}'
DELTA_NODE_KEY="725394672587b34bbf15580c59e5199c75c2c7e998ba8df3cb38cc4347d46e2b"
DELTA_ENODE="ca414c361d1a38716170923e4900d9dc9203dbaf8fdcaee73e1f861df9fdf20a1453b76fd218c18bc6f3c7e13cbca0b3416af02a53b8e31188faa45aab398d1c"
DELTA_NODE_PORT="30307"
DELTA_AUTHRPC_PORT="8555"

# TESTING_ADDRESS is used by the client's internal node.
TESTING_ADDRESS="b6de8bb5ed28e6be6d671975cad20c03931be981"
Expand Down Expand Up @@ -90,6 +94,10 @@ cat > "${NODES_ROOT}/genesis.json" <<EOF
"berlinBlock": 0,
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"mergeNetSplitBlock": 0,
"shanghaiBlock": 0,
"cancunBlock": 0,
"clique": {
"period": 1,
"epoch": 30000
Expand All @@ -111,7 +119,7 @@ cat > "${NODES_ROOT}/genesis.json" <<EOF
"1D4F2ee206474B136Af4868B887C7b166693c194": {
"balance": "11000000000000000000000"
},
"1c8F908d99F62522F8E0AD9504FFcC187e5514ca": {
"946dfaB1AD7caCFeF77dE70ea68819a30acD4577": {
"balance": "11000000000000000000000"
}
}
Expand Down Expand Up @@ -248,23 +256,23 @@ echo "Starting simnet alpha node"
"${HARNESS_DIR}/create-node.sh" "$SESSION:1" "alpha" "$ALPHA_NODE_PORT" \
"$CHAIN_ADDRESS" "$PASSWORD" "$CHAIN_ADDRESS_JSON" \
"$CHAIN_ADDRESS_JSON_FILE_NAME" "$ALPHA_ADDRESS_JSON" "$ALPHA_ADDRESS_JSON_FILE_NAME" \
"$ALPHA_NODE_KEY" "snap"
"$ALPHA_NODE_KEY" "snap" "$ALPHA_AUTHRPC_PORT"

echo "Starting simnet beta node"
"${HARNESS_DIR}/create-node.sh" "$SESSION:2" "beta" "$BETA_NODE_PORT" \
"$CHAIN_ADDRESS" "$PASSWORD" "$CHAIN_ADDRESS_JSON" \
"$CHAIN_ADDRESS_JSON_FILE_NAME" "$BETA_ADDRESS_JSON" "$BETA_ADDRESS_JSON_FILE_NAME" \
"$BETA_NODE_KEY" "snap"
"$BETA_NODE_KEY" "snap" "$BETA_AUTHRPC_PORT"

echo "Starting simnet gamma node"
"${HARNESS_DIR}/create-node.sh" "$SESSION:3" "gamma" "$GAMMA_NODE_PORT" \
"_" "_" "_" "_" "$GAMMA_ADDRESS_JSON" "$GAMMA_ADDRESS_JSON_FILE_NAME" \
"$GAMMA_NODE_KEY" "light"
"$GAMMA_NODE_KEY" "light" "$GAMMA_AUTHRPC_PORT"

echo "Starting simnet delta node"
"${HARNESS_DIR}/create-node.sh" "$SESSION:4" "delta" "$DELTA_NODE_PORT" \
"_" "_" "_" "_" "$DELTA_ADDRESS_JSON" "$DELTA_ADDRESS_JSON_FILE_NAME" \
"$DELTA_NODE_KEY" "light"
"$DELTA_NODE_KEY" "light" "$DELTA_AUTHRPC_PORT"

sleep 1

Expand Down

0 comments on commit 1acf1cf

Please sign in to comment.