patractlabs / redspot

Redspot is an Substrate pallet-contracts (ink!) development environment. Compile your contracts and run them on a different networks. Redspot's core forks from Hardhat but changed a lot to suit substrate.
https://redspot.patract.io/
Other
67 stars 22 forks source link

Value of a storage field of type string is queried incorrectly in test #131

Closed tk-o closed 3 years ago

tk-o commented 3 years ago

I am using a simple Erc20 smart contract, that allows including its name and symbol. Here's how I define getters for these two fields.

I noticed, that the value stored in the smart contract is exactly (byte by byte) the same as the one passed into the contract's constructor. So far so good.

But when I query any of these fields, I get the 2 extra bytes at the beginning of the stored value:

image

Because of these 2 extra bytes, I can't really assert equality in my tests, as the returned value is pre-fixed with 2 extra bytes.

image

Where these 2 extra bytes come from? I also tested using Vec<u8> as a return type for getters. Same story: the value in the contract storage is exactly the same, while the value returned into JS runtime has 2 extra bytes at the beginning.

ii-ii-ii commented 3 years ago

This should be a solved issue. You can try to upgrade to the latest version v0.11.9-0 (Note that it is all redspot related dependencies. including redspot @redspot/patract etc.)

tk-o commented 3 years ago

@ii-ii-ii, thank you for a prompt response! I'll give it a try 🤞

tk-o commented 3 years ago

Nice, the dependencies update solved the issue. Thanks @ii-ii-ii 🤝