From 9381e5f4c5b1328875d00165ea3d128b830138c1 Mon Sep 17 00:00:00 2001 From: Yang Hau Date: Wed, 6 Sep 2023 16:42:32 +0200 Subject: [PATCH] test: Fix cluster test testOffledgerRequest900KB --- .../cluster/tests/offledger_requests_test.go | 44 ++++++++++++++++--- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/tools/cluster/tests/offledger_requests_test.go b/tools/cluster/tests/offledger_requests_test.go index de85fe6c6a..e12a288010 100644 --- a/tools/cluster/tests/offledger_requests_test.go +++ b/tools/cluster/tests/offledger_requests_test.go @@ -18,6 +18,8 @@ import ( "github.com/iotaledger/wasp/packages/kv/dict" "github.com/iotaledger/wasp/packages/vm/core/accounts" "github.com/iotaledger/wasp/packages/vm/core/blob" + "github.com/iotaledger/wasp/packages/vm/core/governance" + "github.com/iotaledger/wasp/packages/vm/gas" ) func TestOffledgerRequestAccessNode(t *testing.T) { @@ -103,21 +105,53 @@ func testOffledgerRequest900KB(t *testing.T, e *ChainEnv) { randomData := make([]byte, size) _, err := rand.Read(randomData) require.NoError(t, err) - paramsDict := dict.Dict{"data": randomData} expectedHash := blob.MustGetBlobHash(paramsDict) + // raise gas limits, gas cost for 900KB has exceeded the limits + { + limits1 := *gas.LimitsDefault + limits1.MaxGasPerRequest = 10 * limits1.MaxGasPerRequest + limits1.MaxGasExternalViewCall = 10 * limits1.MaxGasExternalViewCall + govClient := e.Chain.SCClient(governance.Contract.Hname(), e.Chain.OriginatorKeyPair) + gasLimitsReq, err := govClient.PostOffLedgerRequest( + governance.FuncSetGasLimits.Name, + chainclient.PostRequestParams{ + Args: dict.Dict{ + governance.ParamGasLimitsBytes: limits1.Bytes(), + }, + }, + ) + require.NoError(t, err) + _, _, err = e.Clu.WaspClient(0).ChainsApi. + WaitForRequest(context.Background(), e.Chain.ChainID.String(), gasLimitsReq.ID().String()). + TimeoutSeconds(10). + Execute() + require.NoError(t, err) + + retDict, err := govClient.CallView(context.Background(), + governance.ViewGetGasLimits.Name, + dict.Dict{}, + ) + require.NoError(t, err) + limits2, err := gas.LimitsFromBytes(retDict.Get(governance.ParamGasLimitsBytes)) + require.Equal(t, limits1, *limits2) + require.NoError(t, err) + } + offledgerReq, err := chClient.PostOffLedgerRequest(context.Background(), blob.Contract.Hname(), blob.FuncStoreBlob.Hname(), chainclient.PostRequestParams{ - Args: paramsDict, - }) + Args: paramsDict, + Allowance: isc.NewAssetsBaseTokens(10 * isc.Million), + }, + ) require.NoError(t, err) - _, err = e.Chain.CommitteeMultiClient().WaitUntilRequestProcessedSuccessfully(e.Chain.ChainID, offledgerReq.ID(), false, 30*time.Second) + _, err = e.Chain.CommitteeMultiClient(). + WaitUntilRequestProcessedSuccessfully(e.Chain.ChainID, offledgerReq.ID(), false, 30*time.Second) require.NoError(t, err) - // ensure blob was stored by the cluster res, _, err := e.Chain.Cluster.WaspClient(2).CorecontractsApi. BlobsGetBlobValue(context.Background(), e.Chain.ChainID.String(), expectedHash.Hex(), "data").