Skip to content

Commit

Permalink
[GA] run encointer node in docker image in CI + fix integration tests (
Browse files Browse the repository at this point in the history
…#104)

* [GA] run encointer node in docker image in CI

* [node-api/e2e-ksm] fix test name

* [node-api/e2e] apply lint

* [node-api/e2e] minor registering refactoring and fix ordering of registrations

* bump encointer node docker image

* [node-api/e2e] give funds to charlie again

* [node-api/e2e] update transfer tx to transferKeepAlive
  • Loading branch information
clangenb authored May 13, 2024
1 parent 791e671 commit fdc979f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 44 deletions.
17 changes: 1 addition & 16 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,8 @@ jobs:
- name: Run yarn install
run: yarn install

- name: Download encointer-node
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: build-and-test.yml
name: encointer-node-notee-3e805e3283a7348ff70f22224478db5b5366395b
# in fact this action should download the latest artifact, but sometimes fails. Then we need to
# set the `run_id` to force a download of an updated binary.
run_id: 6253043495
path: node
repo: encointer/encointer-node

- name: Run encointer-node
run: |
ls -alt node
chmod +x node/encointer-node-notee
./node/encointer-node-notee --tmp --dev --enable-offchain-indexing true --rpc-methods unsafe &
run: ./scripts/docker_run_encointer_node_notee.sh &

- name: Run integration tests
run: yarn test:integration
Expand Down
2 changes: 1 addition & 1 deletion packages/node-api/src/e2e-ksm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('node-api', () => {
describe('rpc', () => {
// These tests predominantly verify that we have correct rpc/type definitions
describe('encointer', () => {
it('encointer.GetAllCommunities should return empty vec', async () => {
it('encointer.GetAllCommunities should return LEU community', async () => {
// @ts-ignore
const cidNames = await api.rpc.encointer.getAllCommunities();
expect(cidNames[0].cid).toStrictEqual(cidLeu);
Expand Down
48 changes: 21 additions & 27 deletions packages/node-api/src/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,34 +307,18 @@ async function registerAliceBobCharlieAndGoToAttesting(api: ApiPromise, cid: Com
const bob = keyring.addFromUri('//Bob', {name: 'Bob default'});
const charlie = keyring.addFromUri('//Charlie', {name: 'Charlie default'});

// Even though they are identical, we need to have three different objects because they are passed by reference in JS.
const tx1 = api.tx['encointerCeremonies']['registerParticipant'](cid, null)
const tx2 = api.tx['encointerCeremonies']['registerParticipant'](cid, null)
const tx3 = api.tx['encointerCeremonies']['registerParticipant'](cid, null)

// Charlie does not have funds
const transfer_tx = api.tx['balances']['transfer'](charlie.address, 10000000000000);
const transfer_tx = api.tx['balances']['transferKeepAlive'](charlie.address, 10000000000000);
await submitAndWatchTx(api, alice, transfer_tx)
.then((result) => {
if (result.error !== undefined) {
console.log(`failed fund Charlie: ${JSON.stringify(result)}`);
}
})

let results = await Promise.all([
submitAndWatchTx(api, alice, tx1),
submitAndWatchTx(api, bob, tx2),
submitAndWatchTx(api, charlie, tx3),
])

const signers = [alice, bob, charlie];
results.forEach((result, index) => {
if (result.error !== undefined) {
console.log(`failed register ${signers[index].address}: ${JSON.stringify(result)}`);
} else {
console.log(`registered ${signers[index].address}: result: ${JSON.stringify(result)}`);
}
})
await registerParticipant(api, alice, cid);
await registerParticipant(api, bob, cid);
await registerParticipant(api, charlie, cid);

// go to assigning phase
await nextPhase(api, alice);
Expand All @@ -343,16 +327,26 @@ async function registerAliceBobCharlieAndGoToAttesting(api: ApiPromise, cid: Com
await nextPhase(api, alice);
}

function nextPhase(api: ApiPromise, signer: KeyringPair): Promise<void> {
async function registerParticipant(api: ApiPromise, signer: KeyringPair, cid: CommunityIdentifier): Promise<void> {
const tx = api.tx['encointerCeremonies']['registerParticipant'](cid, null)

const result = await submitAndWatchTx(api, signer, tx)

if (result.error !== undefined) {
console.log(`failed register ${signer.address}: ${JSON.stringify(result)}`);
} else {
console.log(`registered ${signer.address}: result: ${JSON.stringify(result)}`);
}
}

async function nextPhase(api: ApiPromise, signer: KeyringPair): Promise<void> {
const tx = api.tx['sudo']['sudo'](
api.tx['encointerScheduler']['nextPhase']()
);
return submitAndWatchTx(api, signer, tx)
.then((result) => {
if (result.error !== undefined) {
console.log(`failed to go to next phase: ${JSON.stringify(result)}`);
}
});
let result = await submitAndWatchTx(api, signer, tx);
if (result.error !== undefined) {
console.log(`failed to go to next phase: ${JSON.stringify(result)}`);
}
}

const defaultDemurrage = 2078506789235;
Expand Down
14 changes: 14 additions & 0 deletions scripts/docker_run_encointer_node_notee.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
set -euxo pipefail

DOCKER_TAG=${1:-1.8.3}

echo "Encointer node docker tag: ${DOCKER_TAG}"

docker run -p 30333:30333 -p 9944:9944 -p 9933:9933 -p 9615:9615 \
encointer/encointer-node-notee:${DOCKER_TAG} \
--dev \
--enable-offchain-indexing true \
--rpc-methods unsafe \
-lencointer=debug,parity_ws=warn \
--rpc-external \

0 comments on commit fdc979f

Please sign in to comment.