Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add wrapper subinvoke test case #1328

Merged
merged 4 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/js/client/src/__tests__/e2e/test-cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,6 @@ export const runSubinvokeTest = async (

if (!response.ok) fail(response.error);
expect(response.value).toBeTruthy();
expect(response.value).toEqual("1 + 2 = 3");
expect(response.value).toEqual(3);
}
};
8 changes: 1 addition & 7 deletions packages/js/client/src/__tests__/e2e/wasm-as.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe("wasm-as test cases", () => {
await TestCases.runAsyncifyTest(client, wrapperUri);
});

it("subinvoke", async() => {
it.only("subinvoke", async() => {
const wrapperPath = `${GetPathToTestWrappers()}/wasm-as/simple-subinvoke/invoke`;
const wrapperUri = `fs/${wrapperPath}/build`;

Expand All @@ -50,12 +50,6 @@ describe("wasm-as test cases", () => {
await buildWrapper(wrapperPath);

const client = await getClient({
plugins: [
{
uri: "wrap://ens/memory-storage.polywrap.eth",
plugin: makeMemoryStoragePlugin({}),
},
],
redirects: [
{
from: "ens/add.eth",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "test-case-simple-invoke",
"private": true,
"dependencies": {
"@polywrap/wasm-as": "0.3.0",
"@polywrap/wasm-as": "0.9.1",
"assemblyscript": "0.19.1"
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,3 @@ source:
import_abis:
- uri: ens/add.eth
abi: ../subinvoke/build/wrap.info
extensions:
build: ./polywrap.build.yaml
meta: ./polywrap.meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import * into Add from "ens/add.eth"

type Module {
add(a: Int!, b: Int!): String!
add(a: Int!, b: Int!): Int!
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { Args_add, Add_Module } from "./wrap";
import { Args_add as ImportedArgs_add } from "./wrap/imported/Add_Module/serialization";

export function add(args: Args_add): string {
Add_Module.add
export function add(args: Args_add): i32 {
let importedArgs: ImportedArgs_add = {
a: args.a,
b: args.b
}
return Add_Module.add(importedArgs).unwrap()
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? I'd prefer to have a different output for invoke and subinvoke. It'll be easy to debug and spot some horrible bugs that would be passed safely due to a buggy client implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it just to make it work and have a super simple example

I'd prefer to have a different output for invoke and subinvoke

Gotcha, if we just use the add method in the invoke and add 1 to that result, would that be enough for you? Meaning that the invoke method would return the sum of two numbers + 1, and the subinvoke would just return the sum of two numbers

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that'd work. You can call it add_and_increament then

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "test-case-simple-subinvoke",
"private": true,
"dependencies": {
"@polywrap/wasm-as": "0.3.0",
"@polywrap/wasm-as": "0.9.1",
"assemblyscript": "0.19.1"
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@ project:
source:
schema: ./schema.graphql
module: ./src/index.ts
extensions:
build: ./polywrap.build.yaml
meta: ./polywrap.meta.yaml