Skip to content

Commit

Permalink
ci: fix kgw test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaiba authored and jchappelow committed May 20, 2024
1 parent 36347c8 commit 8176ce1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
16 changes: 6 additions & 10 deletions .github/workflows/kgw-test-reuse.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -205,30 +205,26 @@ jobs:
# clone kwil-js
git clone https://github.com/kwilteam/kwil-js.git /tmp/kwil-js
cd /tmp/kwil-js
# find the latest tag if kjs-ref is a tag
if [[ ${{ inputs.kjs-ref }} == v0.* ]]; then
kjs_ref=`git tag -l | grep ${{ inputs.kjs-ref }} | sort | tail -n 1`
else
kjs_ref=${{ inputs.kjs-ref }}
fi
# kwil-js release branch is v0.x
kjs_ref=${{ inputs.kjs-ref }}
echo "====== checkout kwil-js ref: $kjs_ref"
git checkout $kjs_ref
# build kwil-js
npm install
npm run build
# run tests
chain_id=`curl -s http://localhost:8080/api/v1/chain_info | jq -r .chain_id`
chain_id=`curl -s -H "content-type: application/json" -d '{"jsonrpc":"2.0","method":"user.chain_info","params":null,"id":1}' http://localhost:8484/rpc/v1 | jq -r .result.chain_id`
echo "run kgw in docker"
docker run --name kgwcontainer -d --rm --network kwil_kwilnet0 -p 8090:8090 kgw:latest \
--devmode -d "http://localhost:8090" \
--cors-allow-origins "*" \
-b "http://kwild:8080" \
-b "http://kwild:8484" \
--chain-id $chain_id \
--allow-adhoc-query \
--allow-deploy-db \
--log-level debug
echo "run KWIL-JS TEST against kwild(http:localhost:8080), with $chain_id"
PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000001 CHAIN_ID=$chain_id GATEWAY_ON=false GAS_ON=false KWIL_PROVIDER=http://localhost:8080 npm run integration
echo "run KWIL-JS TEST against kwild(http:localhost:8484), with $chain_id"
PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000001 CHAIN_ID=$chain_id GATEWAY_ON=false GAS_ON=false KWIL_PROVIDER=http://localhost:8484 npm run integration
echo "run KWIL-JS TEST against kgw(http://localhost:8090), with $chain_id"
# assume the test above will drop the database, so we can deploy again
PRIVATE_KEY=0000000000000000000000000000000000000000000000000000000000000001 CHAIN_ID=$chain_id GATEWAY_ON=true GAS_ON=false KWIL_PROVIDER=http://localhost:8090 npm run integration
Expand Down
12 changes: 7 additions & 5 deletions test/specifications/eth_deposits.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,12 @@ func DeployDbInsufficientFundsSpecification(ctx context.Context, t *testing.T, d
txHash, err := deployer.DeployDatabase(ctx, db)
require.NoError(t, err, "failed to send deploy database tx")

// Then i expect success
// Then i expect failure
expectTxFail(t, deployer, ctx, txHash, defaultTxQueryTimeout)()

// And i expect database should exist
time.Sleep(2 * time.Second) // ensure sync from other nodes

// And i expect database should not exist
err = deployer.DatabaseExists(ctx, deployer.DBID(db.Name))
require.Error(t, err)

Expand Down Expand Up @@ -241,7 +243,7 @@ func DeployDbSuccessSpecification(ctx context.Context, t *testing.T, deployer De
require.NoError(t, err)
senderAddr := ec.PubkeyToAddress(sender.PublicKey).Bytes()

// I approve 10 tokens
// I approve deployPrice+10 tokens
amount := big.NewInt(0).Add(deployPrice, big.NewInt(10))
err = deployer.Approve(ctx, sender, amount)
require.NoError(t, err)
Expand Down Expand Up @@ -270,7 +272,7 @@ func DeployDbSuccessSpecification(ctx context.Context, t *testing.T, deployer De
// Then i expect success
expectTxSuccess(t, deployer, ctx, txHash, defaultTxQueryTimeout)()

time.Sleep(2 * time.Second)
time.Sleep(2 * time.Second) // ensure sync from other nodes

// And i expect database should exist
err = deployer.DatabaseExists(ctx, deployer.DBID(db.Name))
Expand All @@ -281,7 +283,7 @@ func DeployDbSuccessSpecification(ctx context.Context, t *testing.T, deployer De
require.NoError(t, err)

var diff = big.NewInt(0)
// User balance reduced to 0, as it submitted a deploy request without sufficient funds
// assume deployPrice is spent
require.Equal(t, diff.Sub(postDeployBalance, preUserBalance), big.NewInt(10))
}

Expand Down

0 comments on commit 8176ce1

Please sign in to comment.