Skip to content

Commit

Permalink
Fix system tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayashsatolia403 committed Aug 25, 2024
1 parent 3516323 commit fb506c9
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 34 deletions.
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.1

require (
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.16.1
github.com/0chain/gosdk v1.17.0-RC4.0.20240824190709-96c7a58bb85c
github.com/go-resty/resty/v2 v2.7.0
github.com/herumi/bls-go-binary v1.31.0
github.com/shopspring/decimal v1.3.1
Expand All @@ -15,15 +15,14 @@ require (
github.com/stretchr/testify v1.8.4
github.com/tyler-smith/go-bip39 v1.1.0
github.com/ybbus/jsonrpc/v3 v3.1.5 // nolint
golang.org/x/crypto v0.24.0
golang.org/x/crypto v0.26.0
gopkg.in/errgo.v2 v2.1.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/gorm v1.24.1
)

require (
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/hack-pad/go-webworkers v0.1.0 // indirect
github.com/hack-pad/safejs v0.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect
Expand Down Expand Up @@ -101,10 +100,10 @@ require (
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.dedis.ch/fixbuf v1.0.3 // indirect
go.dedis.ch/kyber/v3 v3.1.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565 h1:z+DtCR8mBsjPnEs
github.com/0chain/common v0.0.6-0.20230127095721-8df4d1d72565/go.mod h1:UyDC8Qyl5z9lGkCnf9RHJPMektnFX8XtCJZHXCCVj8E=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.16.1 h1:mJyVjc5zDs7x6ssAJoPTG6ULNfIKwU1NxveVwaRisK4=
github.com/0chain/gosdk v1.16.1/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/0chain/gosdk v1.17.0-RC4.0.20240824190709-96c7a58bb85c h1:w0eb2+4KHxr/T+aQlRjmbqho/KTOaCB73l25M5hjV5E=
github.com/0chain/gosdk v1.17.0-RC4.0.20240824190709-96c7a58bb85c/go.mod h1:/PXIXnUGWUXqtl9vP3qHfvD+OD7f7TqS9GsWW7YjVGg=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Luzifer/go-openssl/v3 v3.1.0 h1:QqKqo6kYXGGUsvtUoCpRZm8lHw+jDfhbzr36gVj+/gw=
Expand Down Expand Up @@ -451,8 +451,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw=
golang.org/x/crypto v0.26.0/go.mod h1:GY7jblb9wI+FOo5y8/S2oY4zWP07AkOJ4+jxCqdqn54=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -528,8 +528,8 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -550,8 +550,8 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190124100055-b90733256f2e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -604,8 +604,8 @@ golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand All @@ -622,8 +622,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

coreClient "github.com/0chain/gosdk/core/client"
"github.com/0chain/gosdk/zcncore"
"github.com/0chain/system_test/internal/api/model"
"github.com/0chain/system_test/internal/api/util/client"
Expand All @@ -23,8 +24,7 @@ func TestClientSendNonceGreaterThanFutureNonceLimit(testSetup *testing.T) {
wallet1 := initialisedWallets[walletIdx]
walletIdx++

err := zcncore.SetWallet(*wallet1.ToZCNCryptoWallet(wallet1.Mnemonics), false)
require.NoError(t, err)
coreClient.SetWallet(*wallet1.ToZCNCryptoWallet(wallet1.Mnemonics))

faucetAmount := float64(9)
balResp := apiClient.GetWalletBalance(t, wallet1, client.HttpOkStatus)
Expand Down Expand Up @@ -64,8 +64,7 @@ func TestClientSendSameNonceForDifferentTransactions(testSetup *testing.T) {
wallet1 := initialisedWallets[walletIdx]
walletIdx++

err := zcncore.SetWallet(*wallet1.ToZCNCryptoWallet(wallet1.Mnemonics), false)
require.NoError(t, err)
coreClient.SetWallet(*wallet1.ToZCNCryptoWallet(wallet1.Mnemonics))

faucetAmount := float64(9)
balResp := apiClient.GetWalletBalance(t, wallet1, client.HttpOkStatus)
Expand Down Expand Up @@ -183,8 +182,7 @@ func TestClientSendTransactionToOnlyOneMiner(testSetup *testing.T) {
wallet1 := initialisedWallets[walletIdx]
walletIdx++

err := zcncore.SetWallet(*wallet1.ToZCNCryptoWallet(wallet1.Mnemonics), false)
require.NoError(t, err)
coreClient.SetWallet(*wallet1.ToZCNCryptoWallet(wallet1.Mnemonics))

faucetAmount := float64(9)
balResp := apiClient.GetWalletBalance(t, wallet1, client.HttpOkStatus)
Expand Down
15 changes: 13 additions & 2 deletions tests/api_tests/main_test.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package api_tests

import (
"context"
"encoding/json"
coreClient "github.com/0chain/gosdk/core/client"

Check failure on line 6 in tests/api_tests/main_test.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/golangci/golangci-lint (goimports)
"github.com/0chain/gosdk/core/conf"
"log"
"os"
"strconv"
"sync"
"testing"
"time"

"github.com/0chain/gosdk/zcncore"
"github.com/0chain/system_test/internal/api/model"
"github.com/0chain/system_test/internal/api/util/client"
"github.com/0chain/system_test/internal/api/util/config"
Expand Down Expand Up @@ -63,7 +65,16 @@ func TestMain(m *testing.M) {

t := test.NewSystemTest(new(testing.T))

err = zcncore.Init(getConfigForZcnCoreInit(parsedConfig.BlockWorker))
err = coreClient.Init(context.Background(), conf.Config{
BlockWorker: parsedConfig.BlockWorker,
SignatureScheme: "bls0chain",
ChainID: "0afc093ffb509f059c55478bc1a60351cef7b4e9c008a53a6cc8241ca8617dfe",
PreferredBlobbers: nil,
MaxTxnQuery: 5,
QuerySleepTime: 5,
MinSubmit: 10,
MinConfirmation: 10,
})
require.NoError(t, err)

blobberOwnerWalletMnemonics = parsedConfig.BlobberOwnerWalletMnemonics
Expand Down
19 changes: 12 additions & 7 deletions tests/cli_tests/sdk.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package cli_tests

import (
"context"
"crypto/rand"
"encoding/json"
"fmt"
"github.com/0chain/gosdk/core/client"

Check failure on line 7 in tests/cli_tests/sdk.go

View workflow job for this annotation

GitHub Actions / lint

File is not `goimports`-ed with -local github.com/golangci/golangci-lint (goimports)
"io"
"math/big"
"os"

"github.com/0chain/gosdk/core/conf"
"github.com/0chain/gosdk/zboxcore/fileref"
"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/0chain/gosdk/zcncore"
)

func InitSDK(wallet, configFile string) error {
Expand All @@ -30,11 +30,16 @@ func InitSDK(wallet, configFile string) error {
return err
}

marshal, err := json.Marshal(parsed)
if err != nil {
return err
}
err = zcncore.Init(string(marshal))
err = client.Init(context.Background(), conf.Config{
BlockWorker: parsed.BlockWorker,
SignatureScheme: parsed.SignatureScheme,
ChainID: parsed.ChainID,
PreferredBlobbers: nil,
MaxTxnQuery: 5,
QuerySleepTime: 5,
MinSubmit: 10,
MinConfirmation: 10,
})
if err != nil {
return err
}
Expand Down

0 comments on commit fb506c9

Please sign in to comment.