From f01b1ba596572634eda4fe3c43aa1bba4ac4e52f Mon Sep 17 00:00:00 2001 From: Pierre Seznec Date: Thu, 19 Oct 2023 10:48:38 +0200 Subject: [PATCH] testnet26 tests --- int/config/config_network.yaml | 6 +++--- pkg/node/events.go | 3 ++- pkg/node/sendoperation/sendoperation.go | 3 ++- pkg/onchain/website/uploader.go | 18 +++++++++++++----- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/int/config/config_network.yaml b/int/config/config_network.yaml index fe378260a..3be610020 100644 --- a/int/config/config_network.yaml +++ b/int/config/config_network.yaml @@ -1,13 +1,13 @@ testnet: - DNS: AS12MGDGVB3xNDqzGidJM5fcAbjF1ZP5XAecm5ww4RU7sfQd4cMKk + DNS: AS12dCHtafNAiQMDFMoiyPqU1kX1S1Nn4PdAGvW9ffBueDW7JmLMP URLs: - - https://test.massa.net/api/v2 + - http://81.49.155.238:33035 + Default: true buildnet: DNS: AS1pzpVk79cubdM7Zk9pNdg1JR4qKooVa6usyquiCEQhPeRWD9k7 URLs: - https://buildnet.massa.net/api/v2 - Default: true labnet: DNS: AS1PV17jWkbUs7mfXsn8Xfs9AK6tHiJoxuGu7RySFMV8GYdMeUSh diff --git a/pkg/node/events.go b/pkg/node/events.go index fe360adfc..017e62436 100644 --- a/pkg/node/events.go +++ b/pkg/node/events.go @@ -131,5 +131,6 @@ func ListenEvents( } return nil, - fmt.Errorf("listening events for: opId %s, caller %s, emitter %s: Timeout", *operationID, *caller, *emitter) + // fmt.Errorf("listening events for: opId %s, caller %s, emitter %s: Timeout", *operationID, *caller, *emitter) + fmt.Errorf("timeout while listening events") } diff --git a/pkg/node/sendoperation/sendoperation.go b/pkg/node/sendoperation/sendoperation.go index dd131d7a6..8c617e3f1 100644 --- a/pkg/node/sendoperation/sendoperation.go +++ b/pkg/node/sendoperation/sendoperation.go @@ -20,6 +20,7 @@ const ( DefaultFee = 0 accountCreationStorageCost = 1_000_000 StorageCostPerByte = 100_000 + StorageEntryBaseBytes = 4 OneMassa = 1_000_000_000 ) @@ -234,7 +235,7 @@ func StorageCostForEntry(nodeVersion string, keyByteLengh, valueByteLenght int) return (valueByteLenght + 10) * lecagyStorageCost, nil } - return (valueByteLenght + keyByteLengh) * StorageCostPerByte, nil + return (valueByteLenght + keyByteLengh + StorageEntryBaseBytes) * StorageCostPerByte, nil } func AccountCreationStorageCost(nodeVersion string) (int, error) { diff --git a/pkg/onchain/website/uploader.go b/pkg/onchain/website/uploader.go index d5cfa35dc..eeaedbf40 100644 --- a/pkg/onchain/website/uploader.go +++ b/pkg/onchain/website/uploader.go @@ -34,20 +34,24 @@ func PrepareForUpload( ) (string, string, error) { client := node.NewClient(network.NodeURL) - basePath := "sc/" - - scSuffix := ".wasm" - versionFloat, err := strconv.ParseFloat(network.Version, 64) if err != nil { return "", "", fmt.Errorf("failed to parse nodeversion %s: %w", network.Version, err) } + scSuffix := ".wasm" + //nolint:gomnd if versionFloat >= 26 { // current version is higher than 26.0 scSuffix = "_v26.wasm" + logger.Info("USING TESTNET 26 contract!: ") + } + logger.Info("TESTNET 26 scSuffix: ", scSuffix) + logger.Info("TESTNET 26 len([]byte(ownerKey): ", len([]byte(ownerKey))) + + basePath := "sc/" websiteDeployer, err := content.ReadFile(basePath + "websiteDeployer" + scSuffix) if err != nil { @@ -66,7 +70,7 @@ func PrepareForUpload( return "", "", fmt.Errorf("unable to compute storage cost for website init: %w", err) } - deployCost, err := sendOperation.StorageCostForEntry(network.Version, 0, len(websiteStorer)) + deployCost, err := sendOperation.StorageCostForEntry(network.Version, -4, len(websiteStorer)) if err != nil { return "", "", fmt.Errorf("unable to compute storage cost for website deployment: %w", err) } @@ -76,6 +80,10 @@ func PrepareForUpload( return "", "", fmt.Errorf("unable to compute storage cost for account creation: %w", err) } + logger.Info("deployCost: ", deployCost) + logger.Info("webSiteInitCost: ", webSiteInitCost) + logger.Info("accountCreationCost: ", accountCreationCost) + totalStorageCost := webSiteInitCost + deployCost + accountCreationCost logger.Debug("Website deployment cost estimation: ", totalStorageCost)