Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run adder test on CI
  • Loading branch information
obrok committed Dec 19, 2022
commit a063c84de6e90766444e7782c336a5ff385f2517
12 changes: 12 additions & 0 deletions .github/actions/run-e2e-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ inputs:
follow-up-finalization-check:
description: 'Whether to run a follow-up finalization check.'
required: false
deploy-adder:
description: 'Whether to deploy the adder sample contract to the node.'
required: false
default: 'false'

runs:
using: 'composite'
Expand Down Expand Up @@ -84,6 +88,14 @@ runs:
)
fi

DEPLOY_ADDER="${{ inputs.deploy-adder }}"

if [[ "${DEPLOY_ADDER}" = "true" ]]; then
pushd contracts/adder
export ADDER=$(./deploy.sh)
popd
fi

./.github/scripts/run_e2e_test.sh "${ARGS[@]}"

- name: Run finalization e2e test
Expand Down
4 changes: 4 additions & 0 deletions .github/scripts/run_e2e_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ if [[ -n "${ONLY_LEGACY:-}" ]]; then
ARGS+=(-e ONLY_LEGACY)
fi

if [[ -n "${ADDER:-}" ]]; then
ARGS+=(-e "${ADDER}")
fi

docker run -v $(pwd)/docker/data:/data "${ARGS[@]}" aleph-e2e-client:latest

exit $?
15 changes: 15 additions & 0 deletions .github/workflows/e2e-tests-main-devnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,21 @@ jobs:
UPGRADE_FINALIZATION_WAIT_SESSIONS: 2
timeout-minutes: 10

run-e2e-adder-contract-test:
needs: [build-test-docker, build-test-client]
name: Run e2e adder contract test
runs-on: ubuntu-20.04
steps:
- name: Checkout source code
uses: actions/checkout@v2

- name: Run e2e test
uses: ./.github/actions/run-e2e-test
with:
deploy-adder: true
test-case: adder
timeout-minutes: 2

# The tests below were written under the assumption that nonfinalized blocks are being produced, they need a rewrite before being reenabled.
# TODO(A0-1644): Reenable these tests.
# run-e2e-failing-version-upgrade:
Expand Down
15 changes: 15 additions & 0 deletions contracts/adder/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

NODE_URL="${NODE_URL:-ws://localhost:9944}"
AUTHORITY="${AUTHORITY:-//Alice}"

cargo contract build --release --quiet 1>&2
cargo contract upload --url "$NODE_URL" --suri "$AUTHORITY" --quiet 1>&2

export ADDER

ADDER=$(
cargo contract instantiate --url "$NODE_URL" --suri "$AUTHORITY" --skip-confirm --output-json \
| jq -r ".contract"
)
echo "$ADDER"
13 changes: 2 additions & 11 deletions contracts/adder/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#![cfg_attr(not(feature = "std"), no_std)]

//! This is a simple example contract for use with e2e tests of the aleph-client contract interaction.

#[ink::contract]
mod adder {
/// Defines the storage of your contract.
/// Add new fields to the below struct in order
/// to add new static storage fields to your contract.
#[ink(storage)]
pub struct Adder {
/// Stores a single `bool` value on the storage.
value: u32,
}

Expand All @@ -23,17 +21,11 @@ mod adder {
}

impl Adder {
/// Constructor that initializes the `bool` value to `false`.
///
/// Constructors can delegate to other constructors.
#[ink(constructor)]
pub fn new() -> Self {
Self { value: 0 }
}

/// A message that can be called on instantiated contracts.
/// This one flips the value of the stored `bool` from `true`
/// to `false` and vice versa.
#[ink(message)]
pub fn add(&mut self, value: u32) -> Result<(), Error> {
self.value = self.value.checked_add(value).ok_or(Error::Overflow)?;
Expand All @@ -45,7 +37,6 @@ mod adder {
Ok(())
}

/// Simply returns the current value of our `bool`.
#[ink(message)]
pub fn get(&self) -> u32 {
self.value
Expand Down