-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fe85d5
commit 4c7c887
Showing
20 changed files
with
123 additions
and
509 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AssemblyScript Integration Tests | ||
|
||
This project is for testing the SDK together with the VM project. This is used internally to validate if the functions act like they are supposed to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { jsonArrToUint8Array, JSON, testutils } from '../../as-sdk/assembly/index'; | ||
|
||
export function testValidUint8JsonArray(): void { | ||
const raw: string = "[0, 23, 254, 88]"; | ||
const json = <JSON.Arr>JSON.parse(raw); | ||
const result = jsonArrToUint8Array(json); | ||
|
||
const expected = new Uint8Array(4); | ||
expected.set([0, 23, 254, 88]); | ||
|
||
testutils.assert(result.byteLength === expected.byteLength, "bytelength is not equal"); | ||
testutils.assert( | ||
String.UTF8.decode(result.buffer) === String.UTF8.decode(expected.buffer), | ||
'buffers are not equal' | ||
); | ||
|
||
testutils.ok(); | ||
} | ||
|
||
export function testInvalidUint8JsonArray(): void { | ||
const raw: string = '[0, 23, 299, 88]'; | ||
const json = <JSON.Arr>JSON.parse(raw); | ||
jsonArrToUint8Array(json); | ||
|
||
testutils.error("Test should fail"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { readFile } from "fs/promises"; | ||
import { callVm } from "../../../dist/libs/vm/src"; | ||
|
||
describe('json-utils', () => { | ||
it('should handle valid u8 json arrays', async () => { | ||
const wasmBinary = await readFile( | ||
'dist/libs/as-sdk-integration-tests/debug.wasm' | ||
); | ||
const result = await callVm({ | ||
args: ['testValidUint8JsonArray'], | ||
envs: {}, | ||
binary: new Uint8Array(wasmBinary), | ||
}); | ||
|
||
console.log(result); | ||
|
||
expect(result.resultAsString).toEqual('ok'); | ||
expect(result.exitCode).toBe(0); | ||
}); | ||
|
||
it('should error on invalid u8 json arrays', async () => { | ||
const wasmBinary = await readFile( | ||
'dist/libs/as-sdk-integration-tests/debug.wasm' | ||
); | ||
const result = await callVm({ | ||
args: ['testInvalidUint8JsonArray'], | ||
envs: {}, | ||
binary: new Uint8Array(wasmBinary), | ||
}); | ||
|
||
console.log(result); | ||
|
||
expect(result.stderr).toContain('abort: Invalid u8 299'); | ||
expect(result.exitCode).toBe(255); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AssemblyScript SDK | ||
|
||
SDK for creating Data Requests on the SEDA chain |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
// The entry file of your WebAssembly module. | ||
import Process from './process'; | ||
import * as testutils from './test-utils'; | ||
|
||
|
||
export { JSON, JSONDecoder, JSONEncoder, DecoderState, JSONHandler, ThrowingJSONHandler } from '../../../node_modules/assemblyscript-json/assembly/index'; | ||
export { httpFetch, HttpFetchMethod, HttpFetchOptions, HttpResponse } from './http'; | ||
export { PromiseStatus } from './promise'; | ||
export { Process }; | ||
export { Process, testutils }; | ||
export { jsonArrToUint8Array } from './json-utils'; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import Process from './process'; | ||
|
||
@inline | ||
export function assert(expected: bool, message: string): void { | ||
if (!expected) { | ||
Process.exit_with_message(1, message); | ||
} | ||
} | ||
|
||
@inline | ||
export function ok(message: string = "ok"): void { | ||
Process.exit_with_message(0, message); | ||
} | ||
|
||
@inline | ||
export function error(message: string = "error"): void { | ||
Process.exit_with_message(1, message); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SEDA VM | ||
|
||
Virtual Machine used for testing your Data Request using JavaScript |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.