diff --git a/.github/workflows/gcp-test-deploy.yml b/.github/workflows/gcp-test-deploy.yml index 2904d301..27d488f0 100644 --- a/.github/workflows/gcp-test-deploy.yml +++ b/.github/workflows/gcp-test-deploy.yml @@ -19,10 +19,14 @@ on: test_variables: required: true type: string - zebra_state_path: + root_state_path: required: false type: string default: '/zebrad-cache' + zebra_state_dir: + required: false + type: string + default: '' disk_prefix: required: false type: string @@ -110,7 +114,7 @@ jobs: ${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} \ && \ docker run ${{ inputs.test_variables }} -t --name ${{ inputs.test_id }} \ - --mount type=volume,src=${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }},dst=${{ inputs.zebra_state_path }} \ + --mount type=volume,src=${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }},dst=${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} \ ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}" - name: Get state version from constants.rs @@ -243,7 +247,7 @@ jobs: ${{ inputs.disk_prefix }}-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }} \ && \ docker run ${{ inputs.test_variables }} -t --name ${{ inputs.test_id }} \ - --mount type=volume,src=${{ inputs.disk_prefix }}-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }},dst=${{ inputs.zebra_state_path }} \ + --mount type=volume,src=${{ inputs.disk_prefix }}-${{ inputs.test_id }}-${{ env.GITHUB_SHA_SHORT }},dst=${{ inputs.root_state_path }}/${{ inputs.zebra_state_dir }} \ ${{ env.GAR_BASE }}/${{ env.IMAGE_NAME }}:sha-${{ env.GITHUB_SHA_SHORT }}" - name: Delete test instance diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index cc58f244..186f4008 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -198,7 +198,7 @@ jobs: test-stateful-sync: needs: build uses: ./.github/workflows/gcp-test-deploy.yml - if: ${{ github.event.inputs.regenerate-disks != 'true' }} + if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }} with: test_id: sync-past-checkpoint test_description: Test full validation sync from a cached state @@ -228,10 +228,11 @@ jobs: disk_suffix: tip height_grep_text: 'finished initial sync to chain tip, using gossiped blocks sync_percent=100.* current_height=Height' + # Test that Zebra can answer a synthetic RPC call, using a cached Zebra tip state lightwalletd-rpc-test: - if: ${{ github.event.inputs.regenerate-disks != 'true' }} needs: build uses: ./.github/workflows/gcp-test-deploy.yml + if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }} with: app_name: lightwalletd test_id: fully-synced-rpc @@ -240,4 +241,22 @@ jobs: needs_zebra_state: true saves_to_disk: false disk_suffix: tip - zebra_state_path: '/var/cache' + root_state_path: '/var/cache' + zebra_state_dir: 'zebrad-cache' + + # Test that Zebra can handle a lightwalletd send transaction RPC call, using a cached Zebra tip state + # TODO: use a cached lightwalletd tip state to speed up the test (#4303) + lightwalletd-transactions-test: + needs: build + uses: ./.github/workflows/gcp-test-deploy.yml + if: ${{ github.event.inputs.regenerate-disks != 'true' && github.event.inputs.run-full-sync != 'true' }} + with: + app_name: lightwalletd + test_id: lwd-send-transactions + test_description: Test sending transactions via lightwalletd + test_variables: '-e TEST_LWD_TRANSACTIONS=1 -e ZEBRA_TEST_LIGHTWALLETD=1 -e ZEBRA_FORCE_USE_COLOR=1 -e ZEBRA_CACHED_STATE_DIR=/var/cache/zebrad-cache -e LIGHTWALLETD_DATA_DIR=/var/cache/lightwalletd-cache' + needs_zebra_state: true + saves_to_disk: false + disk_suffix: tip + root_state_path: '/var/cache' + zebra_state_dir: 'zebrad-cache' \ No newline at end of file diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index e2df8cf5..30e2b0bf 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -14,6 +14,8 @@ case "$1" in exec cargo "test" "--locked" "--release" "--features" "enable-sentry,test_sync_past_mandatory_checkpoint_${NETWORK,,}" "--manifest-path" "zebrad/Cargo.toml" "sync_past_mandatory_checkpoint_${NETWORK,,}" elif [[ "$TEST_LWD_RPC_CALL" -eq "1" ]]; then exec cargo "test" "--locked" "--release" "--features" "enable-sentry" "--test" "acceptance" "--" "--nocapture" "--ignored" "fully_synced_rpc_test" + elif [[ "$TEST_LWD_TRANSACTIONS" -eq "1" ]]; then + exec cargo "test" "--locked" "--release" "--features" "enable-sentry" "--test" "acceptance" "--" "--nocapture" "--ignored" "sending_transactions_using_lightwalletd" else exec "$@" fi diff --git a/zebrad/tests/acceptance.rs b/zebrad/tests/acceptance.rs index 75ca9f62..6776beff 100644 --- a/zebrad/tests/acceptance.rs +++ b/zebrad/tests/acceptance.rs @@ -1526,6 +1526,7 @@ async fn fully_synced_rpc_test() -> Result<()> { /// /// See [`common::lightwalletd::send_transaction_test`] for more information. #[tokio::test] +#[ignore] async fn sending_transactions_using_lightwalletd() -> Result<()> { common::lightwalletd::send_transaction_test::run().await } diff --git a/zebrad/tests/common/lightwalletd/send_transaction_test.rs b/zebrad/tests/common/lightwalletd/send_transaction_test.rs index 7cb2731f..cfc6b2c7 100644 --- a/zebrad/tests/common/lightwalletd/send_transaction_test.rs +++ b/zebrad/tests/common/lightwalletd/send_transaction_test.rs @@ -141,8 +141,8 @@ async fn prepare_partial_sync( cached_zebra_state: PathBuf, ) -> Result<(TempDir, block::Height)> { let partial_sync_path = copy_state_directory(cached_zebra_state).await?; - let partial_sync_state_dir = partial_sync_path.as_ref().join("state"); - let tip_height = load_tip_height_from_state_directory(network, &partial_sync_state_dir).await?; + let tip_height = + load_tip_height_from_state_directory(network, partial_sync_path.as_ref()).await?; Ok((partial_sync_path, tip_height)) } @@ -162,7 +162,7 @@ async fn load_transactions_from_block_after( state_path: &Path, ) -> Result>> { let (_read_write_state_service, mut state, latest_chain_tip, _chain_tip_change) = - start_state_service_with_cache_dir(network, state_path.join("state")).await?; + start_state_service_with_cache_dir(network, state_path).await?; let tip_height = latest_chain_tip .best_tip_height() diff --git a/zebrad/tests/common/lightwalletd/wallet_grpc.rs b/zebrad/tests/common/lightwalletd/wallet_grpc.rs index 5ed23c8a..2bb48ef0 100644 --- a/zebrad/tests/common/lightwalletd/wallet_grpc.rs +++ b/zebrad/tests/common/lightwalletd/wallet_grpc.rs @@ -42,7 +42,7 @@ pub fn spawn_lightwalletd_with_rpc_server( lightwalletd.expect_stdout_line_matches("Starting gRPC server")?; if wait_for_blocks { - lightwalletd.expect_stdout_line_matches("Waiting for block")?; + lightwalletd.expect_stdout_line_matches("[Ww]aiting for block")?; } Ok((lightwalletd, lightwalletd_rpc_port)) }