From ca5cc98ecc6cb44b84b601b76464bffd274d02c8 Mon Sep 17 00:00:00 2001 From: bendanzhentan <136774549+bendanzhentan@users.noreply.github.com> Date: Wed, 18 Oct 2023 10:22:03 +0800 Subject: [PATCH] test: add unit-test.yaml (#15) * test: add unit-test.yaml * ethclient: ensure the close of canceled context --- .github/workflows/unit-test.yaml | 18 ++++++++++++++++++ ethclient/ethclient_test.go | 1 + 2 files changed, 19 insertions(+) create mode 100644 .github/workflows/unit-test.yaml diff --git a/.github/workflows/unit-test.yaml b/.github/workflows/unit-test.yaml new file mode 100644 index 0000000000..ebb619649b --- /dev/null +++ b/.github/workflows/unit-test.yaml @@ -0,0 +1,18 @@ +name: Unit Test + +on: + pull_request: + types: [ opened, synchronize, reopened ] + push: + branches: [main, develop] + +jobs: + unit_test: + name: unit_test + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version: '^1.21.3' + - run: make test diff --git a/ethclient/ethclient_test.go b/ethclient/ethclient_test.go index c22446f6f3..0ec2f9e97a 100644 --- a/ethclient/ethclient_test.go +++ b/ethclient/ethclient_test.go @@ -491,6 +491,7 @@ func testTransactionInBlockInterrupted(t *testing.T, client *rpc.Client) { // Test tx in block interrupted. ctx, cancel := context.WithCancel(context.Background()) cancel() + <-ctx.Done() tx, err := ec.TransactionInBlock(ctx, block.Hash(), 0) if tx != nil { t.Fatal("transaction should be nil")