Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into positive_tc_sprint-…
Browse files Browse the repository at this point in the history
…1.13
  • Loading branch information
CristalWilsonLobo committed Feb 19, 2024
2 parents 0e03eb2 + 79bb902 commit 0d2a4fb
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 41 deletions.
214 changes: 214 additions & 0 deletions .github/workflows/ci-dev-st.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
name: "DEV-ST.DEVNET-0CHAIN.NET"
run-name: "System tests [${{ github.ref_name }}] - [${{ github.event.head_commit.message }}]"
concurrency:
group: "system-tests-${{ github.ref }}-${{ github.event_name }}"
cancel-in-progress: true
on:
push:
branches: [ master, staging, sprint* ]
pull_request:
workflow_dispatch:
inputs:
repo_snapshots_branch:
description: 'branch of repo-snapshots to derive images and branches from.'
default: 'current-sprint'
required: true
existing_network:
description: '(OPTIONAL): *EXISTING NETWORK* to run system tests against *INSTEAD OF* deploying a new network. [example: dev.0chain.net]'
default: ''
required: false
test_file_filter:
description: 'Comma separated list of test files to run (eg. zwalletcli_send_and_balance_test.go). If supplied, the PR will NOT be notified of the test result'
default: ''
required: false
run_smoke_tests:
description: 'Only run smoke tests (subset of system tests for fast feedback)'
default: 'false'
required: false

jobs:
golangci:
# if: github.event_name == 'push'
name: "lint"
runs-on: [ arc-runner ]
steps:
- name: Install Packages
run: |
sudo apt-get update
sudo apt-get -y install build-essential nghttp2 libnghttp2-dev libssl-dev
- uses: actions/setup-go@v3
with:
go-version: '1.20'
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.52.2
skip-build-cache: true
skip-pkg-cache: true
only-new-issues: true

ensure-master-is-green:
# if: github.ref != 'refs/heads/master'
name: "Ensure master is green"
runs-on: arc-runner
steps:
- name: Check CI
id: check-ci
uses: 0chain/actions/get-build-state@master
with:
github_token: ${{ github.token }}
repository: "0chain/system_test"
sha: master
- name: Success
if: ${{ env.BUILD_STATE == 'success' }}
run: echo "master is successful!"
- name: Not Successful
if: ${{ env.BUILD_STATE != 'success' }}
run: |
echo "master is NOT successful! was: [${{ env.BUILD_STATE }}]"
exit 1
system-tests:
name: "System Tests"
runs-on: [ dev-st.devnet-0chain.net ]
timeout-minutes: 150
steps:
- name: "Get current PR"
uses: jwalton/gh-find-current-pr@v1
id: findPr
with:
github-token: ${{ github.token }}

- name: "Set PR status as pending"
uses: 0chain/actions/set-pr-status@master
if: steps.findPr.outputs.number && github.event.inputs.test_file_filter == ''
with:
pr_number: ${{ steps.findPr.outputs.pr }}
description: "System tests running with default config..."
state: "pending"
repository: ${{ github.repository }}
status_name: "0Chain System Tests"
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
github_token: ${{ github.token }}

- name: "Config: Run tests against existing 0Chain network"
if: github.event_name == 'workflow_dispatch' && github.event.inputs.existing_network != ''
run: |
echo "NETWORK_URL=$(echo ${{ github.event.inputs.existing_network }})" >> $GITHUB_ENV
echo "TEST_FILE_FILTER=$(echo $(([ -z '${{github.event.inputs.test_file_filter}}' ] && echo '') || echo '${{github.event.inputs.test_file_filter}}'))" >> $GITHUB_ENV
echo "CURRENT_BRANCH=$(echo $(([ -z '${{ github.head_ref }}' ] && echo ${GITHUB_REF#refs/*/}) || echo '${{ github.head_ref }}'))" >> $GITHUB_ENV
echo "REPO_SNAPSHOTS_BRANCH=$(echo $(([ -z '${{github.event.inputs.repo_snapshots_branch}}' ] && echo '<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>') || echo '${{github.event.inputs.repo_snapshots_branch}}'))" >> $GITHUB_ENV
- name: "Config: Deploy new 0Chain network then run tests against it"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
run: |
echo "NETWORK_URL=$(echo dev-st.devnet-0chain.net)" >> $GITHUB_ENV
echo "RUNNER_NUMBER=st" >> $GITHUB_ENV
echo "TEST_FILE_FILTER=$(echo $(([ -z '${{github.event.inputs.test_file_filter}}' ] && echo '') || echo '${{github.event.inputs.test_file_filter}}'))" >> $GITHUB_ENV
echo "CURRENT_BRANCH=$(echo $(([ -z '${{ github.head_ref }}' ] && echo ${GITHUB_REF#refs/*/}) || echo '${{ github.head_ref }}'))" >> $GITHUB_ENV
echo "REPO_SNAPSHOTS_BRANCH=$(echo $(([ -z '${{github.event.inputs.repo_snapshots_branch}}' ] && echo '<CURRENT BRANCH WITH FALLBACK TO CURRENT_SPRINT>') || echo '${{github.event.inputs.repo_snapshots_branch}}'))" >> $GITHUB_ENV
if [[ "${{github.event.inputs.run_smoke_tests}}" == 'true' ]];
then
echo RUN_SMOKE_TESTS=true >> $GITHUB_ENV
else
echo RUN_SMOKE_TESTS=false >> $GITHUB_ENV
fi
- name: 'Setup jq'
uses: dcarbone/[email protected]
with:
version: '1.7'
force: 'false'

- name: "Create Tenderly fork"
run: |
echo "TENDERLY_CREATION_INFO=$(curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{"alias":"mainnet-dev-${{ env.RUNNER_NUMBER }}-${{ github.run_id }}${{ github.run_attempt }}", "description":"", "block_number": 18539779, "network_id":"1"}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork)" >> $GITHUB_ENV
- name: "Parse Tenderly fork creation transaction result"
run: |
echo "TENDERLY_FORK_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.simulation_fork.id')" >> $GITHUB_ENV
echo "TENDERLY_ROOT_TRANSACTION_ID=$(echo '${{ env.TENDERLY_CREATION_INFO }}' | jq -r '.root_transaction.id')" >> $GITHUB_ENV
- name: "Retrieve Tenderly fork block number"
run: |
echo "TENDERLY_FORK_BLOCK_NUMBER=$(curl -X GET \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
https://api.tenderly.co/api/v1/network/1/block-number | jq -r '.block_number')" >> $GITHUB_ENV
echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV
- name: "Transfer Bridge ownership in Tenderly fork"
run: |
echo "TENDERLY_ROOT_TRANSACTION_ID=$(curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{
"network_id": "1",
"block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }},
"transaction_index": null,
"from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4",
"input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97",
"to": "0x7700d773022b19622095118fadf46f7b9448be9b",
"gas": 8000000,
"gas_price": "0",
"value": "0",
"access_list": [],
"generate_access_list": true,
"save": true,
"source": "dashboard",
"block_header": null,
"root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}",
"skip_fork_head_update": false,
"alias": "",
"description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97"
}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate | jq -r '.simulation.id')" >> $GITHUB_ENV
echo "TENDERLY_FORK_BLOCK_NUMBER=$((${{ env.TENDERLY_FORK_BLOCK_NUMBER }} + 1))" >> GITHUB_ENV
- name: "Transfer Authorizers ownership in Tenderly fork"
run: |
curl -X POST \
-H "x-access-key: ${{ secrets.TENDERLY_SECRET }}" \
-H "Content-Type: application/json" \
-d '{
"network_id": "1",
"block_number": ${{ env.TENDERLY_FORK_BLOCK_NUMBER }},
"transaction_index": null,
"from": "0xed8f3170db6d1a71c8fa6d8d73cc2c51db95d5a4",
"input": "0xf2fde38b0000000000000000000000008e25cfd9bd6c0ca67a5522cd920b3c66d39d6e97",
"to": "0x481dab4407b9880de0a68dc62e6af611c4949e42",
"gas": 8000000,
"gas_price": "0",
"value": "0",
"access_list": [],
"generate_access_list": true,
"save": true,
"source": "dashboard",
"block_header": null,
"root": "${{ env.TENDERLY_ROOT_TRANSACTION_ID }}",
"skip_fork_head_update": false,
"alias": "",
"description": "Transfer ownership to 0x8E25cfd9bd6c0ca67a5522cd920b3c66D39d6E97"
}' \
https://api.tenderly.co/api/v1/account/zus_network/project/project/fork/${{ env.TENDERLY_FORK_ID }}/simulate
- name: "Deploy 0Chain"
if: github.event_name == 'push' || github.event.inputs.existing_network == ''
uses: 0chain/actions/deploy-0chain-dev-st@dev-st
with:
repo_snapshots_branch: "${{ env.REPO_SNAPSHOTS_BRANCH }}"
kube_config: ${{ secrets[format('DEVSTKC', env.RUNNER_NUMBER)] }}
teardown_condition: "TESTS_PASSED"
SUBGRAPH_API_URL: ${{ secrets.SUBGRAPH_API_URL }}
TENDERLY_FORK_ID: ${{ env.TENDERLY_FORK_ID }}
graphnode_sc: ${{ secrets.GRAPHNODE_SC }}
graphnode_network: ${{ secrets.GRAPHNODE_NETWORK }}
graphnode_ethereum_node_url: https://rpc.tenderly.co/fork/${{ env.TENDERLY_FORK_ID }}
svc_account_secret: ${{ secrets.SVC_ACCOUNT_SECRET }}
58 changes: 24 additions & 34 deletions tests/api_tests/challenge_timings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,31 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
err error
)

testWallet := initialisedWallets[walletIdx]
walletIdx++
balance := apiClient.GetWalletBalance(t, testWallet, client.HttpOkStatus)
testWallet.Nonce = int(balance.Nonce)
wallet := createWallet(t)

sdkClient.SetWallet(t, testWallet)
sdkClient.SetWallet(t, wallet)

t.TestSetupWithTimeout("Setup", 2*time.Minute, func() {
allBlobbers, resp, err = apiClient.V1SCRestGetAllBlobbers(t, client.HttpOkStatus)
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode())

blobberRequirements := model.DefaultBlobberRequirements(testWallet.Id, testWallet.PublicKey)
blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 3
blobberRequirements.ParityShards = 3

for _, blobber := range allBlobbers {
// stake tokens to this blobber
apiClient.CreateStakePool(t, testWallet, 3, blobber.ID, client.TxSuccessfulStatus, 10.0)
apiClient.CreateStakePool(t, wallet, 3, blobber.ID, client.TxSuccessfulStatus, 10.0)
}

allBlobbers, resp, err = apiClient.V1SCRestGetAllBlobbers(t, client.HttpOkStatus)
require.NoError(t, err)
require.Equal(t, 200, resp.StatusCode())

blobberRequirements.Size = 10 * MB
allocationBlobbers := apiClient.GetAllocationBlobbers(t, testWallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocationWithLockValue(t, testWallet, allocationBlobbers, 10, client.TxSuccessfulStatus)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocationWithLockValue(t, wallet, allocationBlobbers, 10, client.TxSuccessfulStatus)

fileSize := int64(1 * MB)
uploadOp := sdkClient.AddUploadOperation(t, "", "", fileSize)
Expand All @@ -73,15 +70,13 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
t.Cleanup(func() {
for _, blobber := range allBlobbers {
// unstake tokens from this blobber
apiClient.UnlockStakePool(t, testWallet, 3, blobber.ID, client.TxSuccessfulStatus)
apiClient.UnlockStakePool(t, wallet, 3, blobber.ID, client.TxSuccessfulStatus)
}
})

t.RunWithTimeout("1mb file", 1*time.Hour, func(t *test.SystemTest) {
wallet := createWallet(t)

sdkWalletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)

blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
t.Log("Blobber Requirements:", blobberRequirements)
Expand All @@ -91,8 +86,8 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)

// Update wallet nonce
sdkWalletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)
allocationID := apiClient.CreateAllocationWithLockValue(t, wallet, allocationBlobbers, 10, client.TxSuccessfulStatus)

alloc, err := sdk.GetAllocation(allocationID)
Expand All @@ -118,10 +113,8 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
t.RunWithTimeout("10mb file", 1*time.Hour, func(t *test.SystemTest) {
time.Sleep(1 * time.Minute)

wallet := createWallet(t)

sdkWalletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)

blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 1
Expand All @@ -131,8 +124,8 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
t.Log("Blobber Requirements:", blobberRequirements)

// Update wallet nonce
sdkWalletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocationWithLockValue(t, wallet, allocationBlobbers, 10, client.TxSuccessfulStatus)

Expand All @@ -157,11 +150,9 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
})

t.RunWithTimeout("100mb file", 1*time.Hour, func(t *test.SystemTest) {
wallet := createWallet(t)

time.Sleep(2 * time.Minute)
sdkWalletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)

blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 1
Expand All @@ -171,8 +162,8 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
t.Log("Blobber Requirements:", blobberRequirements)

// Update wallet nonce
sdkWalletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocationWithLockValue(t, wallet, allocationBlobbers, 100, client.TxSuccessfulStatus)

Expand All @@ -197,11 +188,10 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
})

t.RunWithTimeout("1gb file", 1*time.Hour, func(t *test.SystemTest) {

Check failure on line 190 in tests/api_tests/challenge_timings_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)

Check failure on line 190 in tests/api_tests/challenge_timings_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)

Check failure on line 190 in tests/api_tests/challenge_timings_test.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary leading newline (whitespace)
wallet := createWallet(t)

time.Sleep(3 * time.Minute)
sdkWalletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)

blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey)
blobberRequirements.DataShards = 1
Expand All @@ -211,8 +201,8 @@ func TestProtocolChallengeTimings(testSetup *testing.T) {
t.Log("Blobber Requirements:", blobberRequirements)

// Update wallet nonce
sdkWalletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(sdkWalletBalance.Nonce)
walletBalance = apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus)
wallet.Nonce = int(walletBalance.Nonce)
allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus)
allocationID := apiClient.CreateAllocationWithLockValue(t, wallet, allocationBlobbers, 500, client.TxSuccessfulStatus)

Expand Down Expand Up @@ -281,7 +271,7 @@ func getChallengeTimings(t *test.SystemTest, blobbers []*blockchain.StorageNode,

proofGenTimes = append(proofGenTimes, challengeTiming.ProofGenTime) // proof gen time in milliseconds

// Calculate the time difference in milliseconds
// Calculate the time difference in seconds
txnSubmission := challengeTiming.TxnSubmission.ToTime().Sub(challengeTiming.CreatedAtBlobber.ToTime())
txnSubmissions = append(txnSubmissions, int64(txnSubmission.Seconds()))

Expand Down
Loading

0 comments on commit 0d2a4fb

Please sign in to comment.