From e03cd309cfc12478bffb1b3b592f89bc8b6fa053 Mon Sep 17 00:00:00 2001 From: BiancaIalangi Date: Wed, 2 Oct 2024 22:41:11 +0300 Subject: [PATCH] chain sim - CI --- .github/workflows/docker-compose.yml | 10 +++++++ .github/workflows/slow-tests.yml | 27 +++++++++++++++++++ Makefile | 4 +++ contracts/examples/adder/interact/Cargo.toml | 3 +++ contracts/examples/adder/interact/config.toml | 8 +++--- .../adder/interact/src/basic_interact.rs | 18 ++++++------- 6 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/docker-compose.yml create mode 100644 .github/workflows/slow-tests.yml create mode 100644 Makefile diff --git a/.github/workflows/docker-compose.yml b/.github/workflows/docker-compose.yml new file mode 100644 index 0000000000..d6bc3287e2 --- /dev/null +++ b/.github/workflows/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3.9" + +services: + chain-simulator: + image: multiversx/chainsimulator:v1.7.13-patch2 + ports: + - 8085:8085 + volumes: + - "../scripts:/docker/scripts" + entrypoint: "./chainsimulator -log-level *:INFO" \ No newline at end of file diff --git a/.github/workflows/slow-tests.yml b/.github/workflows/slow-tests.yml new file mode 100644 index 0000000000..e3e1a6c3eb --- /dev/null +++ b/.github/workflows/slow-tests.yml @@ -0,0 +1,27 @@ +name: Tests + +on: + push: + branches: [ main, feat/* ] + pull_request: + branches: [ main, feat/* ] + +jobs: + test: + name: Slow + runs-on: ubuntu-latest + steps: + - name: Set up Go 1.x + uses: actions/setup-go@v3 + with: + go-version: 1.20.7 + id: go + + - name: Check out code + uses: actions/checkout@v3 + + - name: Get dependencies + run: | + go get -v -t -d ./... + - name: Slow tests + run: make slow-tests \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000000..6dfcb67f61 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +slow-tests: clean-test + @docker compose -f docker/docker-compose.yml build + @docker compose -f docker/docker-compose.yml up & cargo test --features chain_simulator + @docker compose -f docker/docker-compose.yml down -v \ No newline at end of file diff --git a/contracts/examples/adder/interact/Cargo.toml b/contracts/examples/adder/interact/Cargo.toml index 9de0f0f69f..8cfc684a51 100644 --- a/contracts/examples/adder/interact/Cargo.toml +++ b/contracts/examples/adder/interact/Cargo.toml @@ -20,3 +20,6 @@ path = ".." [dependencies.multiversx-sc-snippets] version = "0.53.2" path = "../../../../framework/snippets" + +[features] +chain_simulator = [] diff --git a/contracts/examples/adder/interact/config.toml b/contracts/examples/adder/interact/config.toml index c6f9a97a1d..aca748706a 100644 --- a/contracts/examples/adder/interact/config.toml +++ b/contracts/examples/adder/interact/config.toml @@ -1,5 +1,5 @@ -# chain_type = 'simulator' -# gateway_uri = 'http://localhost:8085' +chain_type = 'simulator' +gateway_uri = 'http://localhost:8085' -chain_type = 'real' -gateway_uri = 'https://devnet-gateway.multiversx.com' +# chain_type = 'real' +# gateway_uri = 'https://devnet-gateway.multiversx.com' diff --git a/contracts/examples/adder/interact/src/basic_interact.rs b/contracts/examples/adder/interact/src/basic_interact.rs index 27a3bbb166..bad2ccccf0 100644 --- a/contracts/examples/adder/interact/src/basic_interact.rs +++ b/contracts/examples/adder/interact/src/basic_interact.rs @@ -280,13 +280,13 @@ impl AdderInteract { } } +#[cfg(feature = "chain_simulator")] #[tokio::test] -#[ignore = "run on demand"] -async fn upgrade_test() { +async fn simulator_upgrade_test() { let mut basic_interact = AdderInteract::init().await; - let wallet_address = basic_interact.wallet_address.clone(); + // let wallet_address = basic_interact.wallet_address.clone(); let adder_owner_address = basic_interact.adder_owner_address.clone(); - let error_not_owner = (4, "upgrade is allowed only for owner"); + // let error_not_owner = (4, "upgrade is allowed only for owner"); basic_interact.deploy().await; basic_interact.add(1u32).await; @@ -301,10 +301,10 @@ async fn upgrade_test() { // Sum will be the updated value of 7 basic_interact.print_sum().await; - basic_interact - .upgrade(10u32, &wallet_address, Some(error_not_owner)) - .await; + // basic_interact + // .upgrade(10u32, &wallet_address, Some(error_not_owner)) + // .await; - // Sum will remain 7 - basic_interact.print_sum().await; + // // Sum will remain 7 + // basic_interact.print_sum().await; }