Skip to content

Commit

Permalink
test: Fix cluster test testOffledgerRequest900KB
Browse files Browse the repository at this point in the history
  • Loading branch information
howjmay committed Sep 6, 2023
1 parent 29f5119 commit 9381e5f
Showing 1 changed file with 39 additions and 5 deletions.
44 changes: 39 additions & 5 deletions tools/cluster/tests/offledger_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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").
Expand Down

0 comments on commit 9381e5f

Please sign in to comment.