diff --git a/.github/workflows/sub-providers.yml b/.github/workflows/sub-providers.yml new file mode 100644 index 000000000..8ea0f70b4 --- /dev/null +++ b/.github/workflows/sub-providers.yml @@ -0,0 +1,95 @@ +name: ❖ Providers + +on: + workflow_dispatch: + inputs: + providers: + description: 'Providers list to test (space separated)' + required: false + default: 'coinbase binance' + stage-url: + description: 'RPC URL' + required: false + default: 'https://staging.rpc.walletconnect.org/' + workflow_call: + inputs: + providers_directory: + type: string + required: true + description: 'Directory where providers sources are located' + stage-url: + type: string + required: true + description: 'Stage RPC URL' + default: 'https://staging.rpc.walletconnect.org/' + +concurrency: cd + +permissions: + contents: write + checks: write + id-token: write + +jobs: + providers-list: + name: "Preparing providers list" + runs-on: ubuntu-latest + outputs: + providers: ${{ steps.set-matrix.outputs.providers }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 2 + - name: Creating list of changed providers + id: set-matrix + run: | + if [[ -n "${{ github.event.inputs.providers }}" ]]; then + PROVIDERS_LIST="${{ github.event.inputs.providers }}" + else + PROVIDERS_DIR="${{ inputs.providers_directory }}" + CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }}) + PROVIDERS_LIST="" + + for file in $CHANGED_FILES; do + if [[ $file == $PROVIDERS_DIR* ]]; then + PROVIDER_TEST_NAME=$(echo $file | sed "s|^$PROVIDERS_DIR||" | sed 's|/|::|g' | sed 's|\.rs$||') + PROVIDERS_LIST+="$PROVIDER_TEST_NAME " + fi + done + + PROVIDERS_LIST="${PROVIDERS_LIST% }" + fi + + JSON_FMT=$(printf '[%s]' "$(echo $PROVIDERS_LIST | awk '{for(i=1;i<=NF;i++) printf "\"%s\",", $i}' | sed 's/,$//')") + echo "providers=$JSON_FMT" >> $GITHUB_OUTPUT + - name: Print list of changed providers + run: | + echo "Providers matrix: ${{ steps.set-matrix.outputs.providers }}" + + providers-test: + name: "Run provider tests" + needs: providers-list + runs-on: ubuntu-latest + if: needs.providers-list.outputs.providers != '[]' + strategy: + fail-fast: false + matrix: + provider: ${{fromJson(needs.providers-list.outputs.providers)}} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: "Install Rust ${{ vars.RUST_VERSION }}" + uses: WalletConnect/actions-rs/toolchain@1.0.0 + with: + toolchain: ${{ vars.RUST_VERSION }} + profile: 'default' + override: true + + - name: Run Tests for ${{ matrix.provider }} + env: + PROJECT_ID: ${{ secrets.PROJECT_ID }} + RPC_URL: ${{ inputs.stage-url }} + run: | + cargo test ${{ matrix.provider }}_provider -- --ignored diff --git a/tests/functional/README.md b/tests/functional/README.md new file mode 100644 index 000000000..550f702dc --- /dev/null +++ b/tests/functional/README.md @@ -0,0 +1,18 @@ +# Functional integration tests + +The following functional integration tests are presented: + +* Database tests +* Providers tests + * Providers functional tests should be `#[ignore]` by default, because they will run by + the CI workflow specifically when the providers code is changed in the `src/provider` + directory. + * Providers test names should be in the format `{provider_name}_provider` and + `{provider_name}_provider_*` aligning with the provider name file in the + `src/providers` directory. + * Example for the `coinbase` provider: + * Implementation source file: `src/provider/coinbase.rs` + Tests for the `coinbase` provider will run only if this file is changed. + * Tests implementation for the `coinbase` provider can be in any files but should be + `#[ignore]` by default and the test names must starts with the + `coinbase_provider`. diff --git a/tests/functional/http/base.rs b/tests/functional/http/base.rs index eaffc76b5..342b9e469 100644 --- a/tests/functional/http/base.rs +++ b/tests/functional/http/base.rs @@ -6,7 +6,8 @@ use { #[test_context(ServerContext)] #[tokio::test] -async fn eip155_8453_base(ctx: &mut ServerContext) { +#[ignore] +async fn base_provider_eip155_8453_and_84531(ctx: &mut ServerContext) { // Base mainnet check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:8453", "0x2105").await; diff --git a/tests/functional/http/binance.rs b/tests/functional/http/binance.rs index 29d949ad8..34cb370fe 100644 --- a/tests/functional/http/binance.rs +++ b/tests/functional/http/binance.rs @@ -6,7 +6,8 @@ use { #[test_context(ServerContext)] #[tokio::test] -async fn binance_provider(ctx: &mut ServerContext) { +#[ignore] +async fn binance_provider_eip155_56_and_97(ctx: &mut ServerContext) { // Binance mainnet check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:56", "0x38").await; diff --git a/tests/functional/http/pokt.rs b/tests/functional/http/pokt.rs index 23510996a..68590e2ec 100644 --- a/tests/functional/http/pokt.rs +++ b/tests/functional/http/pokt.rs @@ -8,7 +8,8 @@ use { #[test_context(ServerContext)] #[tokio::test] -async fn pokt_provider(ctx: &mut ServerContext) { +#[ignore] +async fn pokt_provider_eip155_43114_and_56_and_100(ctx: &mut ServerContext) { // Avax check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:43114", "0xa86a").await; diff --git a/tests/functional/http/zksync.rs b/tests/functional/http/zksync.rs index 00aedb654..e14509cb7 100644 --- a/tests/functional/http/zksync.rs +++ b/tests/functional/http/zksync.rs @@ -6,7 +6,8 @@ use { #[test_context(ServerContext)] #[tokio::test] -async fn eip155_324_zksync_mainnet(ctx: &mut ServerContext) { +#[ignore] +async fn zksync_provider_eip155_324_and_280(ctx: &mut ServerContext) { // ZkSync mainnet check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:324", "0x144").await; diff --git a/tests/functional/http/zora.rs b/tests/functional/http/zora.rs index 9503edbda..71a2f4f3c 100644 --- a/tests/functional/http/zora.rs +++ b/tests/functional/http/zora.rs @@ -6,7 +6,8 @@ use { #[test_context(ServerContext)] #[tokio::test] -async fn eip155_7777777_zora(ctx: &mut ServerContext) { +#[ignore] +async fn zora_provider_eip155_7777777_and_999(ctx: &mut ServerContext) { // Zora mainnet check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:7777777", "0x76adf1") .await; diff --git a/tests/functional/websocket/infura.rs b/tests/functional/websocket/infura.rs index f16aff36d..f3da753df 100644 --- a/tests/functional/websocket/infura.rs +++ b/tests/functional/websocket/infura.rs @@ -7,7 +7,7 @@ use { #[test_context(ServerContext)] #[tokio::test] #[ignore] -async fn infura_websocket_provider(ctx: &mut ServerContext) { +async fn infura_provider_websocket(ctx: &mut ServerContext) { // Ethereum mainnet check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:1", "0x1").await; diff --git a/tests/functional/websocket/zora.rs b/tests/functional/websocket/zora.rs index cf974878d..6c5127f9f 100644 --- a/tests/functional/websocket/zora.rs +++ b/tests/functional/websocket/zora.rs @@ -6,7 +6,8 @@ use { #[test_context(ServerContext)] #[tokio::test] -async fn zora_websocket_provider(ctx: &mut ServerContext) { +#[ignore] +async fn zora_provider_websocket(ctx: &mut ServerContext) { // Zora mainnet check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:7777777", "0x76adf1") .await;