1

我正在尝试运行以下 mandos 测试,但是在运行时erdpy contract test,测试失败并返回以下错误:FAIL: address in "setState" "newAddresses" field should have SC format: address:the_crowdfunding_contract.

测试代码来自 elrond智能合约教程,第 1 部分

步骤中 SC 地址的正确格式是什么setState

使用的版本:

  • erdpy:1.0.21
  • elrod-wasm:0.22.9
{
  "name": "tutorial_crowdfunding",
  "steps": [
    {
      "step": "setState",
      "accounts": {
        "address:my_address": {
          "nonce": "0",
          "balance": "1,000,000"
        }
      },
      "newAddresses": [
        {
          "creatorAddress": "address:my_address",
          "creatorNonce": "0",
          "newAddress": "address:the_crowdfunding_contract"
        }
      ]
    },
    {
      "step": "scDeploy",
      "tx": {
        "from": "address:my_address",
        "contractCode": "file:../output/tutorial_crowdfunding.wasm",
        "value": "0",
        "gasLimit": "1,000,000",
        "gasPrice": "0"
      },
      "expect": {
        "status": "0",
        "gas": "*",
        "refund": "*"
      }
    },
    {
      "step": "checkState",
      "accounts": {
        "address:my_address": {
          "nonce": "1",
          "balance": "1,000,000"
        },
        "address:the_crowdfunding_contract": {
          "nonce": "0",
          "balance": "0",
          "storage": {
            "''owner": "address:my_address"
          },
          "code": "file:../output/tutorial_crowdfunding.wasm"
        }
      }
    }
  ]
}
4

1 回答 1

1

mandos 中的 SmartContract 地址应使用前缀sc:代替address:

所以正确的测试应该是这样的:

{
  "name": "tutorial_crowdfunding",
  "steps": [
    {
      "step": "setState",
      "accounts": {
        "address:my_address": {
          "nonce": "0",
          "balance": "1,000,000"
        }
      },
      "newAddresses": [
        {
          "creatorAddress": "address:my_address",
          "creatorNonce": "0",
          "newAddress": "sc:the_crowdfunding_contract"
        }
      ]
    },
    {
      "step": "scDeploy",
      "tx": {
        "from": "address:my_address",
        "contractCode": "file:../output/tutorial_crowdfunding.wasm",
        "value": "0",
        "gasLimit": "1,000,000",
        "gasPrice": "0"
      },
      "expect": {
        "status": "0",
        "gas": "*",
        "refund": "*"
      }
    },
    {
      "step": "checkState",
      "accounts": {
        "address:my_address": {
          "nonce": "1",
          "balance": "1,000,000"
        },
        "sc:the_crowdfunding_contract": {
          "nonce": "0",
          "balance": "0",
          "storage": {
            "''owner": "address:my_address"
          },
          "code": "file:../output/tutorial_crowdfunding.wasm"
        }
      }
    }
  ]
}

此外,您的 SmartContract 地址名称可能太长,目前不确定确切的限制。因此,如果在上述更改后错误仍然存​​在,请尝试缩短 SmartContract 名称。

附加说明:文档有些过时。有关更新的信息,您可以查看可与 elrond ide vscode 扩展一起使用的模板。他们也在github上

于 2021-11-14T22:39:56.777 回答