mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-08 12:28:05 +00:00
Tests for dynamically sized byte arrays.
This commit is contained in:
parent
b505332970
commit
7c4fef153e
@ -51,8 +51,8 @@ $ yarn test
|
||||
* [ ] Nested Arrays
|
||||
* [x] Fixed size arrays
|
||||
* [ ] Dynamically-sized arrays
|
||||
* [ ] Dynamically-sized byte array
|
||||
* [ ] Bytes
|
||||
* [x] Dynamically-sized byte array
|
||||
* [x] Bytes
|
||||
* [x] String
|
||||
* [ ] Structs
|
||||
* [x] Get struct value with all members
|
||||
|
@ -270,6 +270,33 @@ describe('Get value from storage', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('dynamically sized byte array', () => {
|
||||
let testBytes: Contract, storageLayout: StorageLayout;
|
||||
|
||||
before(async () => {
|
||||
const TestBytes = await ethers.getContractFactory('TestBytes');
|
||||
testBytes = await TestBytes.deploy();
|
||||
await testBytes.deployed();
|
||||
storageLayout = await getStorageLayout('TestBytes');
|
||||
});
|
||||
|
||||
it('get value for byte array length less than 32 bytes', async () => {
|
||||
const expectedValue = ethers.utils.hexlify(ethers.utils.randomBytes(24));
|
||||
await testBytes.setBytesArray(expectedValue);
|
||||
const blockHash = await getBlockHash();
|
||||
const { value } = await getStorageValue(storageLayout, getStorageAt, blockHash, testBytes.address, 'bytesArray');
|
||||
expect(value).to.equal(expectedValue);
|
||||
});
|
||||
|
||||
it('get value for byte array length more than 32 bytes', async () => {
|
||||
const expectedValue = ethers.utils.hexlify(ethers.utils.randomBytes(100));
|
||||
await testBytes.setBytesArray(expectedValue);
|
||||
const blockHash = await getBlockHash();
|
||||
const { value } = await getStorageValue(storageLayout, getStorageAt, blockHash, testBytes.address, 'bytesArray');
|
||||
expect(value).to.equal(expectedValue);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fixed size arrays', () => {
|
||||
let testFixedArrays: Contract, storageLayout: StorageLayout;
|
||||
const int128Array = [100, 200, 300, 400, 500];
|
||||
|
Loading…
Reference in New Issue
Block a user