diff --git a/go.mod b/go.mod index 8703048339..a0a779de6e 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/0chain/errors v1.0.3 - github.com/0chain/gosdk v1.11.1-0.20240204123736-4997432ef46e + github.com/0chain/gosdk v1.13.0-RC2.0.20240306153005-cb8d73ac4941 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 @@ -22,7 +22,7 @@ require ( require ( github.com/andybalholm/brotli v1.0.5 // indirect github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect - github.com/hitenjain14/fasthttp v0.0.0-20240201092245-8e4835c0e974 // indirect + github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 // indirect github.com/klauspost/compress v1.17.0 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect github.com/minio/sha256-simd v1.0.1 // indirect diff --git a/go.sum b/go.sum index aa09e75d48..daa522d555 100644 --- a/go.sum +++ b/go.sum @@ -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.11.1-0.20240204123736-4997432ef46e h1:jp32bMKBQB0X7hTy965p9FayT3V5+LRdSjyDZYuHlAM= -github.com/0chain/gosdk v1.11.1-0.20240204123736-4997432ef46e/go.mod h1:ld0CtqdivpMrEoTWA5Z0nbv3A6Q7+w2/cA3iRGCGYS8= +github.com/0chain/gosdk v1.13.0-RC2.0.20240306153005-cb8d73ac4941 h1:SBf50ETWKveeDMVALcE43PAGqLmZm3dE3b26GW81FSY= +github.com/0chain/gosdk v1.13.0-RC2.0.20240306153005-cb8d73ac4941/go.mod h1:RRBLJvF1FsPkG95D+8UxeasgpFxnLO5s7QV2svXg69E= 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= @@ -224,8 +224,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/herumi/bls-go-binary v1.31.0 h1:L1goQ2tMtGgpXCg5AwHAdJQpLs/pfnWWEc3Wog6OhmI= github.com/herumi/bls-go-binary v1.31.0/go.mod h1:O4Vp1AfR4raRGwFeQpr9X/PQtncEicMoOe6BQt1oX0Y= -github.com/hitenjain14/fasthttp v0.0.0-20240201092245-8e4835c0e974 h1:oEjH9SSKBlzwDyYjzZaqRpxo7GlfUJCyRoOk7QHKSDs= -github.com/hitenjain14/fasthttp v0.0.0-20240201092245-8e4835c0e974/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk= +github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17 h1:FbyIK0BfvXVZTOxKOe2dlxJqSPSF2ZXOv2Mc7dvS7sc= +github.com/hitenjain14/fasthttp v0.0.0-20240229173600-722723e15e17/go.mod h1:RZMcXy7u4S+E97IXYTe7WHZ3+mCYOh4vys8PkIGZeXk= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= diff --git a/internal/api/util/client/sdk.go b/internal/api/util/client/sdk.go index 7de67acc1c..dcbffc65a3 100644 --- a/internal/api/util/client/sdk.go +++ b/internal/api/util/client/sdk.go @@ -261,6 +261,9 @@ func (c *SDKClient) AddUploadOperation(t *test.SystemTest, path, format string, FileMeta: fileMeta, Workdir: homeDir, RemotePath: fileMeta.RemotePath, + Opts: []sdk.ChunkedUploadOption{ + sdk.WithChunkNumber(120), + }, } } diff --git a/tests/api_tests/repair_allocation_test.go b/tests/api_tests/repair_allocation_test.go index b0bdcc3bda..63dc53a323 100644 --- a/tests/api_tests/repair_allocation_test.go +++ b/tests/api_tests/repair_allocation_test.go @@ -27,7 +27,7 @@ func TestRepairAllocation(testSetup *testing.T) { blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey) blobberRequirements.DataShards = 2 blobberRequirements.ParityShards = 2 - blobberRequirements.Size = 2056 + blobberRequirements.Size = 240 * MB allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus) allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus) @@ -35,7 +35,7 @@ func TestRepairAllocation(testSetup *testing.T) { require.NoError(t, err) lastBlobber := alloc.Blobbers[0] alloc.Blobbers[0].Baseurl = "http://0zus.com/" - op := sdkClient.AddUploadOperation(t, "", "") + op := sdkClient.AddUploadOperation(t, "", "", 100*MB) sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}, client.WithRepair(alloc.Blobbers)) sdkClient.RepairAllocation(t, allocationID) diff --git a/tests/api_tests/stream_upload_test.go b/tests/api_tests/stream_upload_test.go new file mode 100644 index 0000000000..1a01de914b --- /dev/null +++ b/tests/api_tests/stream_upload_test.go @@ -0,0 +1,34 @@ +package api_tests + +import ( + "testing" + + "github.com/0chain/gosdk/zboxcore/sdk" + "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/test" + "github.com/stretchr/testify/require" +) + +func TestStreamUpload(testSetup *testing.T) { + t := test.NewSystemTest(testSetup) + t.SetSmokeTests("Stream upload should work") + + t.RunSequentially("Stream upload should work", func(t *test.SystemTest) { + wallet := initialisedWallets[walletIdx] + walletIdx++ + balance := apiClient.GetWalletBalance(t, wallet, client.HttpOkStatus) + wallet.Nonce = int(balance.Nonce) + sdkClient.SetWallet(t, wallet) + blobberRequirements := model.DefaultBlobberRequirements(wallet.Id, wallet.PublicKey) + blobberRequirements.Size = 150 * MB + allocationBlobbers := apiClient.GetAllocationBlobbers(t, wallet, &blobberRequirements, client.HttpOkStatus) + allocationID := apiClient.CreateAllocation(t, wallet, allocationBlobbers, client.TxSuccessfulStatus) + op := sdkClient.AddUploadOperation(t, "", "", 100*MB) + op.FileMeta.ActualSize = 0 + op.StreamUpload = true + sdkClient.MultiOperation(t, allocationID, []sdk.OperationRequest{op}) + listResult := sdkClient.GetFileList(t, allocationID, "/") + require.Equal(t, 1, len(listResult.Children), "files count mismatch expected %v actual %v", 10, len(listResult.Children)) + }) +}