Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/ End to End #394

Merged
merged 22 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
52dcee6
tmp: e2e test requirements
scorpioborn Apr 25, 2024
1750b25
test: add balance check to e2e
scorpioborn Apr 25, 2024
a85f034
test: e2e grant signup reward and balances
scorpioborn Apr 26, 2024
d6f4170
test: fix minter provision after network test integration
scorpioborn Apr 30, 2024
9353a1b
test: rearange e2e test dirs
scorpioborn Apr 30, 2024
bc53357
Merge pull request #390 from scorpioborn/test/e2e-init
scorpioborn Apr 30, 2024
26a4f44
test: e2e house deposity
scorpioborn May 3, 2024
9e52f60
test: house withdraw
scorpioborn May 13, 2024
19a8e5b
test: house withdraw with authz
scorpioborn May 13, 2024
757155c
lint: ignore testhelper gosec
scorpioborn May 13, 2024
268f404
lint: unnecessary gosec ignore directive
scorpioborn May 13, 2024
8139438
Merge pull request #395 from scorpioborn/test/e2e-house
scorpioborn May 14, 2024
e5452cd
test: e2e bet
scorpioborn May 20, 2024
b18d765
lint: remove unused valbalance
scorpioborn May 20, 2024
7164d65
Merge pull request #397 from scorpioborn/test/e2e-bet
scorpioborn May 22, 2024
1e8605f
refactor: e2e tests name overlap
scorpioborn May 23, 2024
3250163
fix(workflows): upgrade checkout
scorpioborn May 23, 2024
b68d50c
Merge branch 'release/v1.7.x' into test/e2e
scorpioborn May 23, 2024
1081c00
fix(workflows): download artifact v4
scorpioborn May 23, 2024
64429f3
test: e2e market add and grps
scorpioborn May 27, 2024
0e237ec
lint: remove duplicate
scorpioborn Jun 6, 2024
b09a9f2
Merge pull request #408 from scorpioborn/test/e2e-market
scorpioborn Jun 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@master
- uses: actions/checkout@v4
- uses: technote-space/get-diff-action@v4
with:
PATTERNS: |
Expand Down
36 changes: 19 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ jobs:
arch: arm64

steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Get git diff
uses: technote-space/[email protected]
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- uses: technote-space/get-diff-action@v4
id: git_diff
with:
PATTERNS: |
**/**.wasm
Expand Down Expand Up @@ -82,23 +84,23 @@ jobs:
go-version: 1.22
- uses: actions/checkout@v4
- name: Create a file with all the pkgs
run: go list ./... > pkgs.txt
run: go list ./... | grep -E -v 'tests/e2e' > pkgs.txt
- name: Split pkgs into 4 files
run: split -d -n l/4 pkgs.txt pkgs.txt.part.
# cache multiple
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-00"
path: ./pkgs.txt.part.00
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-01"
path: ./pkgs.txt.part.01
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-02"
path: ./pkgs.txt.part.02
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-03"
path: ./pkgs.txt.part.03
Expand All @@ -121,15 +123,15 @@ jobs:
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-${{ matrix.part }}"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -coverprofile=${{ matrix.part }}profile.out -covermode=atomic -tags='norace ledger test_ledger_mock'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-${{ matrix.part }}-coverage"
path: ./${{ matrix.part }}profile.out
Expand All @@ -145,19 +147,19 @@ jobs:
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-00-coverage"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-01-coverage"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-02-coverage"
if: env.GIT_DIFF
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-03-coverage"
if: env.GIT_DIFF
Expand Down Expand Up @@ -199,15 +201,15 @@ jobs:
**/**.go
go.mod
go.sum
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v4
with:
name: "${{ github.sha }}-${{ matrix.part }}"
if: env.GIT_DIFF
- name: test & coverage report creation
run: |
xargs --arg-file=pkgs.txt.part.${{ matrix.part }} go test -mod=readonly -timeout 30m -race -tags='cgo ledger test_ledger_mock'
if: env.GIT_DIFF
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: "${{ github.sha }}-${{ matrix.part }}-race-output"
path: ./${{ matrix.part }}-race-output.txt
16 changes: 16 additions & 0 deletions tests/e2e/bet/cli_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package client_test

import (
"testing"

"github.com/stretchr/testify/suite"

client "github.com/sge-network/sge/tests/e2e/bet"
"github.com/sge-network/sge/testutil/network"
)

func TestE2ETestSuite(t *testing.T) {
cfg := network.DefaultConfig()
cfg.NumValidators = 1
suite.Run(t, client.NewE2ETestSuite(cfg))
}
106 changes: 106 additions & 0 deletions tests/e2e/bet/grpc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package client

import (
"fmt"

"github.com/cosmos/gogoproto/proto"

"github.com/cosmos/cosmos-sdk/testutil"
grpctypes "github.com/cosmos/cosmos-sdk/types/grpc"
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/sge-network/sge/x/bet/types"
)

func (s *E2ETestSuite) TestBetsGRPCHandler() {
val := s.network.Validators[0]
baseURL := val.APIAddress

testCases := []struct {
name string
url string
headers map[string]string
respType proto.Message
expected proto.Message
}{
{
"test GRPC Bet by UID",
fmt.Sprintf("%s/sge/bet/%s/%s", baseURL, dummyBetCreator, dummyBetUID),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryBetResponse{},
&types.QueryBetResponse{
Bet: genesis.BetList[0],
Market: dummyMarket,
},
},
{
"test GRPC sorted Bet by creator",
fmt.Sprintf("%s/sge/bet/creator/%s/bets", baseURL, dummyBetCreator),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryBetsByCreatorResponse{},
&types.QueryBetsByCreatorResponse{
Bet: genesis.BetList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
{
"test GRPC Bet by UID",
fmt.Sprintf("%s/sge/bet/bets", baseURL),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryBetsResponse{},
&types.QueryBetsResponse{
Bet: genesis.BetList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
{
"test GRPC pending bets by market",
fmt.Sprintf("%s/sge/bet/bets/pending/%s", baseURL, dummyMarketUID),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QueryPendingBetsResponse{},
&types.QueryPendingBetsResponse{
Bet: genesis.BetList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
{
"test GRPC settled bets by market",
fmt.Sprintf("%s/sge/bet/bets/settled/%d", baseURL, 1),
map[string]string{
grpctypes.GRPCBlockHeightHeader: "1",
},
&types.QuerySettledBetsOfHeightResponse{},
&types.QuerySettledBetsOfHeightResponse{
Bet: genesis.BetList,
Pagination: &query.PageResponse{
Total: 1,
},
},
},
}

for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
resp, err := testutil.GetRequestWithHeaders(tc.url, tc.headers)
s.Require().NoError(err)

s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, tc.respType))
s.Require().Equal(tc.expected.String(), tc.respType.String())
})
}
}
Loading
Loading