Skip to content

Commit 331c852

Browse files
lukedawilsonLuke Wilson
andauthored
Fix scan ordering bug and tendermint tests (#57)
* Fix scan ordering bug * Also fix the tendermint tests * Fix node version Co-authored-by: Luke Wilson <[email protected]>
1 parent 66ce5cd commit 331c852

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
10-
node: ['14.x']
10+
node: ['18.x']
1111
os: [ubuntu-latest]
1212

1313
steps:

src/backend/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export class BasicKVIterStorage extends BasicKVStorage implements IIterStorage {
123123
}
124124

125125
let data: Record[] = [];
126-
for (const key of this.dict.keys()) {
126+
for (const key of Array.from(this.dict.keys()).sort()) {
127127
if (start?.length && compare(start, fromBase64(key)) === 1) continue;
128128
if (end?.length && compare(fromBase64(key), end) > -1) break;
129129

src/helpers/byte-array.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export function toByteArray(number: number, fixedLength?: number | undefined): U
3838
const bytesOriginal = fromHex(hex);
3939

4040
if (!fixedLength) {
41-
return bytesOriginal;
41+
return new Uint8Array([...bytesOriginal]);
4242
}
4343

4444
let bytesFixedLength = [...bytesOriginal];

test/integration/crypto-verify.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const mockEnv = {
1919
contract: {address: mockContractAddr}
2020
};
2121

22-
const mockInfo: { sender: string, funds: { amount: string, denom: string }[] } = {
22+
const mockInfo = {
2323
sender: creator,
2424
funds: []
2525
};
@@ -124,7 +124,7 @@ describe('crypto-verify', () => {
124124
};
125125
const raw = wrapResult(vm.query(mockEnv, verify_msg)).unwrap();
126126
const res = parseBase64Response(raw);
127-
// TODO: Still failing
127+
128128
expect(res).toEqual({
129129
verifies: true,
130130
});
@@ -242,7 +242,7 @@ describe('crypto-verify', () => {
242242
it('tendermint_signature_verify_fails', async () => {
243243
vm.instantiate(mockEnv, mockInfo, {});
244244

245-
const message = testData.ED25519_MESSAGE_HEX;
245+
const message = new Uint8Array([... testData.ED25519_MESSAGE_HEX]);
246246
message[0] ^= 0x01;
247247

248248
const verify_msg = {

test/integration/queue.test.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -148,27 +148,25 @@ describe('queue', () => {
148148
// Arrange
149149
vm.instantiate(mockEnv, mockInfo, {});
150150

151-
for (let i = 0; i < 3; i++) { // ToDo: iterate 37 (0x25) times (currently breaks when you do this)
151+
for (let i = 0; i < 37; i++) {
152152
vm.execute(mockEnv, mockInfo, { enqueue: { value: 40 } });
153153
}
154154

155-
for (let i = 0; i < 2; i++) { // ToDo: iterate 25 (0x19) times (currently breaks when you do this)
155+
for (let i = 0; i < 25; i++) {
156156
vm.execute(mockEnv, mockInfo, { dequeue: {} });
157157
}
158158

159159
// Act
160160
const listResponse = vm.query(mockEnv, { list: {} });
161161

162162
// Assert
163+
const countResponse = vm.query(mockEnv, { count: {} });
164+
expect(parseBase64OkResponse(countResponse)).toEqual({ count: 12 });
165+
163166
const list = parseBase64OkResponse(listResponse);
164167
expect(list.empty).toStrictEqual([]);
165-
expect(list.early).toStrictEqual([1]);
166-
expect(list.late).toStrictEqual([]);
167-
168-
// ToDo: implement asserts from original rust test
169-
// expect(list.empty).toStrictEqual([]);
170-
// expect(list.early).toStrictEqual([25, 26, 27, 28, 29, 30, 31]);
171-
// expect(list.late).toStrictEqual([32, 33, 34, 35, 36]);
168+
expect(list.early).toStrictEqual([25, 26, 27, 28, 29, 30, 31]);
169+
expect(list.late).toStrictEqual([32, 33, 34, 35, 36]);
172170
});
173171

174172
it('query_open_iterators', async () => {

0 commit comments

Comments
 (0)