From 028a57cdb1ae1c6e0a03c74a4a78840ccd48969e Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Thu, 21 Dec 2023 17:52:11 +0000 Subject: [PATCH 01/18] add integration setup - TODO: remove p2p keys / don't copy from containers --- .dockerignore | 5 + .idea/workspace.xml | 258 ++++++++++++++++++ Dockerfile | 6 +- integration_tests/config/genesis.json | 67 +++++ integration_tests/docker-compose.yaml | 76 ++++++ .../keystore.json | 21 ++ .../master.key | 1 + .../keystore.json | 21 ++ .../master.key | 1 + .../keystore.json | 21 ++ .../master.key | 1 + .../keystore.json | 21 ++ .../master.key | 1 + 13 files changed, 497 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 .idea/workspace.xml create mode 100644 integration_tests/config/genesis.json create mode 100644 integration_tests/docker-compose.yaml create mode 100644 integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/keystore.json create mode 100644 integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/master.key create mode 100644 integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/keystore.json create mode 100644 integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/master.key create mode 100644 integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/keystore.json create mode 100644 integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/master.key create mode 100644 integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/keystore.json create mode 100644 integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/master.key diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..3ccd790ee --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.github +*.md +thorest.png +coverage.out +integration_tests diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..27d6723aa --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,258 @@ + + + + + + + + + + + + + { + "lastFilter": { + "state": "OPEN", + "assignee": "darrenvechain" + } +} + + + + + + + + + + + + + + + { + "associatedIndex": 7 +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + + file://$PROJECT_DIR$/api/blocks/blocks.go + 121 + + + file://$PROJECT_DIR$/cmd/thor/flags.go + 62 + + + file://$PROJECT_DIR$/api/api.go + 62 + + + file://$PROJECT_DIR$/api/api.go + 61 + + + + + + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7f6311f87..66a8113ee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build thor in a stock Go builder container -FROM golang:alpine as builder +FROM golang:alpine3.17 as builder RUN apk add --no-cache make gcc musl-dev linux-headers git WORKDIR /go/thor @@ -7,7 +7,7 @@ COPY . /go/thor RUN make all # Pull thor into a second stage deploy alpine container -FROM alpine:latest +FROM alpine:3.17 RUN apk add --no-cache ca-certificates COPY --from=builder /go/thor/bin/thor /usr/local/bin/ @@ -16,4 +16,4 @@ RUN adduser -D -s /bin/ash thor USER thor EXPOSE 8669 11235 11235/udp 55555/udp -ENTRYPOINT ["thor"] \ No newline at end of file +ENTRYPOINT ["thor"] diff --git a/integration_tests/config/genesis.json b/integration_tests/config/genesis.json new file mode 100644 index 000000000..fa320c237 --- /dev/null +++ b/integration_tests/config/genesis.json @@ -0,0 +1,67 @@ +{ + "launchTime": 1703180212, + "gasLimit": 10000000, + "extraData": "My custom VeChain", + "accounts": [ + { + "address": "0x7567d83b7b8d80addcb281a71d54fc7b3364ffed", + "balance": 25000000000000000000000000, + "energy": 0, + "code": "0x6060604052600256", + "storage": { + "0x0000000000000000000000000000000000000000000000000000000000000001": "0x0000000000000000000000000000000000000000000000000000000000000002" + } + }, + { + "address": "0x435933c8064b4ae76be665428e0307ef2ccfbd68", + "balance": 21046908616500000000000000000, + "energy": 0 + }, + { + "address": "0xf370940abdbd2583bc80bfc19d19bc216c88ccf0", + "balance": 21046908616500000000000000000, + "energy": 0 + }, + { + "address": "0x0f872421dc479f3c11edd89512731814d0598db5", + "balance": 21046908616500000000000000000, + "energy": 0 + }, + { + "address": "0x0bd7b06debd1522e75e4b91ff598f107fd826c8a", + "balance": 21046908616500000000000000000, + "energy": 0 + } + ], + "authority": [ + { + "masterAddress": "0x435933c8064b4ae76be665428e0307ef2ccfbd68", + "endorsorAddress": "0x7567d83b7b8d80addcb281a71d54fc7b3364ffed", + "identity": "0x000000000000000068747470733a2f2f636f6e6e65782e76656368612e696e2f" + }, + { + "masterAddress": "0xf370940abdbd2583bc80bfc19d19bc216c88ccf0", + "endorsorAddress": "0x7567d83b7b8d80addcb281a71d54fc7b3364ffed", + "identity": "0x000000000000000068747470733a2f2f656e762e7665636861696e2e6f72672f" + }, + { + "masterAddress": "0x0f872421dc479f3c11edd89512731814d0598db5", + "endorsorAddress": "0x7567d83b7b8d80addcb281a71d54fc7b3364ffed", + "identity": "0x0000000000000068747470733a2f2f617070732e7665636861696e2e6f72672f" + } + ], + "params": { + "rewardRatio": 300000000000000000, + "baseGasPrice": 1000000000000000, + "proposerEndorsement": 25000000000000000000000000, + "executorAddress": "0x0000000000000000000000004578656375746f72" + }, + "executor": { + "approvers": [ + { + "address": "0x199b836d8a57365baccd4f371c1fabb7be77d389", + "identity": "0x00000000000067656e6572616c20707572706f736520626c6f636b636861696e" + } + ] + } +} diff --git a/integration_tests/docker-compose.yaml b/integration_tests/docker-compose.yaml new file mode 100644 index 000000000..d6b99aa5d --- /dev/null +++ b/integration_tests/docker-compose.yaml @@ -0,0 +1,76 @@ +version: "3.8" + +services: + + thor-disco: + build: + context: .. + dockerfile: Dockerfile + container_name: thor-disco + entrypoint: "disco --keyhex=99f0500549792796c14fed62011a51081dc5b5e68fe8bd8a13b86be829c4fd36" + volumes: + - ./config:/node/config + - ./keys/f077b491b355e64048ce21e3a6fc4751eeea77fa:/node/config + networks: + - thor + ports: + - "55556:55555" + + authority-node-1: + build: + context: .. + dockerfile: Dockerfile + container_name: authority-node-1 + entrypoint: "thor --config-dir=/node/keys --network /node/config/genesis.json --bootnode enode://e32e5960781ce0b43d8c2952eeea4b95e286b1bb5f8c1f0c9f09983ba7141d2fdd7dfbec798aefb30dcd8c3b9b7cda8e9a94396a0192bfa54ab285c2cec515ab@172.22.0.2:55555" + volumes: + - type: bind + source: ./config + target: /node/config + - type: bind + source: ./keys/435933c8064b4ae76be665428e0307ef2ccfbd68 + target: /node/keys + networks: + - thor + ports: + - "8669:8669" + + authority-node-2: + build: + context: .. + dockerfile: Dockerfile + container_name: authority-node-2 + entrypoint: "thor --config-dir=/node/keys --network /node/config/genesis.json --bootnode enode://e32e5960781ce0b43d8c2952eeea4b95e286b1bb5f8c1f0c9f09983ba7141d2fdd7dfbec798aefb30dcd8c3b9b7cda8e9a94396a0192bfa54ab285c2cec515ab@172.22.0.2:55555" + volumes: + - type: bind + source: ./config + target: /node/config + - type: bind + source: ./keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0 + target: /node/keys + networks: + - thor + ports: + - "8679:8669" + + authority-node-3: + build: + context: .. + dockerfile: Dockerfile + container_name: authority-node-3 + entrypoint: "thor --config-dir=/node/keys --network /node/config/genesis.json --bootnode enode://e32e5960781ce0b43d8c2952eeea4b95e286b1bb5f8c1f0c9f09983ba7141d2fdd7dfbec798aefb30dcd8c3b9b7cda8e9a94396a0192bfa54ab285c2cec515ab@172.22.0.2:55555" + volumes: + - type: bind + source: ./config + target: /node/config + - type: bind + source: ./keys/0f872421dc479f3c11edd89512731814d0598db5 + target: /node/keys + networks: + - thor + ports: + - "8689:8669" + +networks: + thor: + driver: bridge + name: thor diff --git a/integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/keystore.json b/integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/keystore.json new file mode 100644 index 000000000..a526b0d6e --- /dev/null +++ b/integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/keystore.json @@ -0,0 +1,21 @@ +{ + "address": "0f872421dc479f3c11edd89512731814d0598db5", + "id": "33eda5b7-140d-441d-b450-07ca28fb0105", + "version": 3, + "crypto": { + "cipher": "aes-128-ctr", + "cipherparams": { + "iv": "182b783ea15a49b815042dd3a8bbc80e" + }, + "ciphertext": "2084fac13c2d3b3e45dd743766abcffe5c48e2d8169a895e7891235949fd3506", + "kdf": "scrypt", + "kdfparams": { + "salt": "e5256c7b430ffefda1b1bcbef44af363eddf01ff8dc9112eb97324bfa6d388c6", + "n": 131072, + "dklen": 32, + "p": 1, + "r": 8 + }, + "mac": "b27043563629497c167a756eed7130079e7a4e7c5aa05fde67ed064a14e6f536" + } +} diff --git a/integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/master.key b/integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/master.key new file mode 100644 index 000000000..6848f24f2 --- /dev/null +++ b/integration_tests/keys/0f872421dc479f3c11edd89512731814d0598db5/master.key @@ -0,0 +1 @@ +f4a1a17039216f535d42ec23732c79943ffb45a089fbb78a14daad0dae93e991 diff --git a/integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/keystore.json b/integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/keystore.json new file mode 100644 index 000000000..e3d10a8b0 --- /dev/null +++ b/integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/keystore.json @@ -0,0 +1,21 @@ +{ + "address": "435933c8064b4ae76be665428e0307ef2ccfbd68", + "id": "278224be-550d-4adc-94c1-817e45f6f5f1", + "version": 3, + "crypto": { + "cipher": "aes-128-ctr", + "cipherparams": { + "iv": "8873ddb8810d2337d1f01e3270be12f8" + }, + "ciphertext": "04bfcd9dc4eb86d280fe23209fed323b0067e24dbf8e3169c2062d0e998b6891", + "kdf": "scrypt", + "kdfparams": { + "salt": "8102dd0c6cce78e6166bcd7e49fe203c8965287124e9d8609ccb84b0a4f83620", + "n": 131072, + "dklen": 32, + "p": 1, + "r": 8 + }, + "mac": "dc124531f4fca3fe67214cb6cc1442d71989b476eec1d32667cfec810181c1a1" + } +} diff --git a/integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/master.key b/integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/master.key new file mode 100644 index 000000000..9b14d7aff --- /dev/null +++ b/integration_tests/keys/435933c8064b4ae76be665428e0307ef2ccfbd68/master.key @@ -0,0 +1 @@ +7b067f53d350f1cf20ec13df416b7b73e88a1dc7331bc904b92108b1e76a08b1 diff --git a/integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/keystore.json b/integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/keystore.json new file mode 100644 index 000000000..a46a0fdf4 --- /dev/null +++ b/integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/keystore.json @@ -0,0 +1,21 @@ +{ + "address": "f077b491b355e64048ce21e3a6fc4751eeea77fa", + "id": "7b30e693-a7a5-471b-84d3-f490b4e10349", + "version": 3, + "crypto": { + "cipher": "aes-128-ctr", + "cipherparams": { + "iv": "263b752452068a012cf6245459b57bed" + }, + "ciphertext": "a5330f79204343725b41d7ba29b625284cf7e638b6eb5386ef05d595530c36dc", + "kdf": "scrypt", + "kdfparams": { + "salt": "95c76063d034643794a8616ff7223353f1976e4895da7c1293432870c18557d7", + "n": 131072, + "dklen": 32, + "p": 1, + "r": 8 + }, + "mac": "cafc9a1195bcf0bb0586d416a92c04d716d2364574520cbf11b08dd4566c5b5e" + } +} diff --git a/integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/master.key b/integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/master.key new file mode 100644 index 000000000..8c2d9ed90 --- /dev/null +++ b/integration_tests/keys/f077b491b355e64048ce21e3a6fc4751eeea77fa/master.key @@ -0,0 +1 @@ +99f0500549792796c14fed62011a51081dc5b5e68fe8bd8a13b86be829c4fd36 diff --git a/integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/keystore.json b/integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/keystore.json new file mode 100644 index 000000000..71aeb2254 --- /dev/null +++ b/integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/keystore.json @@ -0,0 +1,21 @@ +{ + "address": "f370940abdbd2583bc80bfc19d19bc216c88ccf0", + "id": "507695ed-8aa6-417f-8a67-8c3cadc669b4", + "version": 3, + "crypto": { + "cipher": "aes-128-ctr", + "cipherparams": { + "iv": "ca4a9ef516f4fb04e9d28864b681d4b2" + }, + "ciphertext": "b07ffd58fbac19ae8968b57d0ad4aaded1931daa1bb5e973a70edfe65e422c19", + "kdf": "scrypt", + "kdfparams": { + "salt": "2cd63ebe7b87b498236a68f856ef02f2b5a723f63305fa92524903054ffd9e39", + "n": 131072, + "dklen": 32, + "p": 1, + "r": 8 + }, + "mac": "4121304545bd976cbe4e8ab7d174597818fd7ef7710f94ae91a5ba1c189d32ae" + } +} diff --git a/integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/master.key b/integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/master.key new file mode 100644 index 000000000..8d6aae573 --- /dev/null +++ b/integration_tests/keys/f370940abdbd2583bc80bfc19d19bc216c88ccf0/master.key @@ -0,0 +1 @@ +35b5cc144faca7d7f220fca7ad3420090861d5231d80eb23e1013426847371c4 From acd6fd788c65dab8d93cad10273d03f826966502 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Fri, 22 Dec 2023 09:50:06 +0000 Subject: [PATCH 02/18] testing docker compose in GH Actions --- .github/workflows/integration-tests.yaml | 14 ++++++ .idea/workspace.xml | 13 ++--- integration_tests/config/start.sh | 12 +++++ integration_tests/docker-compose-base.yaml | 21 ++++++++ integration_tests/docker-compose.yaml | 58 ++++++---------------- 5 files changed, 69 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/integration-tests.yaml create mode 100755 integration_tests/config/start.sh create mode 100644 integration_tests/docker-compose-base.yaml diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml new file mode 100644 index 000000000..9f81ab2d3 --- /dev/null +++ b/.github/workflows/integration-tests.yaml @@ -0,0 +1,14 @@ +name: Integration Tests + +on: [push, pull_request] + +jobs: + integration_tests: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Run Compose + run: | + docker-compose -f integration_tests/docker-compose.yaml up diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 27d6723aa..b127c7be6 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,8 @@ - + + + + @@ -125,90 +155,126 @@ + - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - + + + + - - - - + + project + + $PROJECT_DIR$/integration_tests/node_modules/mocha + $PROJECT_DIR$/integration_tests + true + bdd + + SUITE + $PROJECT_DIR$/integration_tests/test/blocks.test.ts + + + - - + + project + + + $PROJECT_DIR$/integration_tests + true + bdd + --require ts-node/register + TEST + $PROJECT_DIR$/integration_tests/test/blocks.test.ts + + + + - - - - - + + project + + $PROJECT_DIR$/integration_tests/node_modules/mocha + $PROJECT_DIR$/integration_tests + true + bdd + + SUITE + $PROJECT_DIR$/integration_tests/test/contracts.test.ts + + + + + + + project + + $PROJECT_DIR$/integration_tests/node_modules/mocha + $PROJECT_DIR$/integration_tests + true + bdd + + TEST + $PROJECT_DIR$/integration_tests/test/contracts.test.ts + + + + - - - - + + + + + - - - + + + + + - - - + - - - - - - - - - - - - + - - - - - - - - - - - - - - - + + + project + + $PROJECT_DIR$/integration_tests/node_modules/mocha + $PROJECT_DIR$/integration_tests + true + bdd + + TEST + $PROJECT_DIR$/integration_tests/test/accounts.test.ts + + + + + + project @@ -244,19 +236,19 @@ + - + - diff --git a/integration_tests/package.json b/integration_tests/package.json index 4725ea508..0ac5e3651 100644 --- a/integration_tests/package.json +++ b/integration_tests/package.json @@ -7,6 +7,7 @@ "license": "MIT", "private": false, "scripts": { + "postinstall": "hardhat compile", "test": "yarn mocha --exit", "generate:accounts": "ts-node scripts/generate-account.ts" }, From 8fe7f183086d8396514c244c9dbb013b762a5d79 Mon Sep 17 00:00:00 2001 From: Darren Kelly Date: Mon, 25 Dec 2023 23:29:51 +0000 Subject: [PATCH 06/18] update actions --- .github/workflows/integration-tests.yaml | 2 +- .idea/workspace.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/integration-tests.yaml b/.github/workflows/integration-tests.yaml index a08662b29..9ac907cbb 100644 --- a/.github/workflows/integration-tests.yaml +++ b/.github/workflows/integration-tests.yaml @@ -11,7 +11,7 @@ jobs: - name: Run Compose run: | - docker-compose -f integration_tests/network/docker-compose.yaml up -d --wait + docker compose -f integration_tests/network/docker-compose.yaml up -d --wait - name: Setup Node uses: actions/setup-node@v3 diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 1f42853b4..26ff2675d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -6,8 +6,6 @@ - -