From 4519c846608476014dfc1adb4c7458d4225bac42 Mon Sep 17 00:00:00 2001 From: blaineheffron Date: Wed, 29 May 2024 18:12:34 -0400 Subject: [PATCH] one liners --- test/e2e/src/test-custom-types.js | 93 +++++++++++-------------------- 1 file changed, 31 insertions(+), 62 deletions(-) diff --git a/test/e2e/src/test-custom-types.js b/test/e2e/src/test-custom-types.js index ea350f74d..778a4eeb0 100644 --- a/test/e2e/src/test-custom-types.js +++ b/test/e2e/src/test-custom-types.js @@ -12,8 +12,7 @@ describe("Custom Types Tests", function() { }); it("hello", async function() { - const { result } = await this.context.client.hello({ hello: "tests" }); - expect(result).to.equal("tests"); + expect((await this.context.client.hello({ hello: "tests" })).result).to.equal("tests"); }); it("view method with empty keypair", async function() { @@ -21,13 +20,11 @@ describe("Custom Types Tests", function() { keypair: undefined, contractId: this.context.contractId, }); - const { result } = await client2.hello({ hello: "anonymous" }); - expect(result).to.equal("anonymous"); + expect((await client2.hello({ hello: "anonymous" })).result).to.equal("anonymous"); }); it("woid", async function() { - const { result } = await this.context.client.woid(); - expect(result).to.be.null; + expect((await this.context.client.woid()).result).to.be.null; }); it("u32_fail_on_even", async function() { @@ -39,54 +36,45 @@ describe("Custom Types Tests", function() { }); it("u32", async function() { - const { result } = await this.context.client.u32_({ u32_: 1 }); - expect(result).to.equal(1); + expect((await this.context.client.u32_({ u32_: 1 })).result).to.equal(1); }); it("i32", async function() { - const { result } = await this.context.client.i32_({ i32_: 1 }); - expect(result).to.equal(1); + expect((await this.context.client.i32_({ i32_: 1 })).result).to.equal(1); }); it("i64", async function() { - const { result } = await this.context.client.i64_({ i64_: 1n }); - expect(result).to.equal(1n); + expect((await this.context.client.i64_({ i64_: 1n })).result).to.equal(1n); }); it("strukt_hel", async function() { const strukt = { a: 0, b: true, c: "world" }; - const { result } = await this.context.client.strukt_hel({ strukt }); - expect(result).to.deep.equal(["Hello", "world"]); + expect((await this.context.client.strukt_hel({ strukt })).result).to.deep.equal(["Hello", "world"]); }); it("strukt", async function() { const strukt = { a: 0, b: true, c: "hello" }; - const { result } = await this.context.client.strukt({ strukt }); - expect(result).to.deep.equal(strukt); + expect((await this.context.client.strukt({ strukt })).result).to.deep.equal(strukt); }); it("simple first", async function() { const simple = { tag: "First", values: undefined }; - const { result } = await this.context.client.simple({ simple }); - expect(result).to.deep.equal({ tag: "First" }); + expect((await this.context.client.simple({ simple })).result).to.deep.equal({ tag: "First" }); }); it("simple second", async function() { const simple = { tag: "Second", values: undefined }; - const { result } = await this.context.client.simple({ simple }); - expect(result).to.deep.equal({ tag: "Second" }); + expect((await this.context.client.simple({ simple })).result).to.deep.equal({ tag: "Second" }); }); it("simple third", async function() { const simple = { tag: "Third", values: undefined }; - const { result } = await this.context.client.simple({ simple }); - expect(result).to.deep.equal({ tag: "Third" }); + expect((await this.context.client.simple({ simple })).result).to.deep.equal({ tag: "Third" }); }); it("complex with struct", async function() { const arg = { tag: "Struct", values: [{ a: 0, b: true, c: "hello" }] }; - const { result } = await this.context.client.complex({ complex: arg }); - expect(result).to.deep.equal(arg); + expect((await this.context.client.complex({ complex: arg })).result).to.deep.equal(arg); }); it("complex with tuple", async function() { @@ -103,71 +91,59 @@ describe("Custom Types Tests", function() { tag: "Tuple", values: [[{ a: 0, b: true, c: "hello" }, { tag: "First" }]], }; - const { result } = await this.context.client.complex({ complex: arg }); - expect(result).to.deep.equal(ret); + expect((await this.context.client.complex({ complex: arg })).result).to.deep.equal(ret); }); it("complex with enum", async function() { const arg = { tag: "Enum", values: [{ tag: "First", values: undefined }] }; const ret = { tag: "Enum", values: [{ tag: "First" }] }; - const { result } = await this.context.client.complex({ complex: arg }); - expect(result).to.deep.equal(ret); + expect((await this.context.client.complex({ complex: arg })).result).to.deep.equal(ret); }); it("complex with asset", async function() { const arg = { tag: "Asset", values: [this.context.publicKey, 1n] }; - const { result } = await this.context.client.complex({ complex: arg }); - expect(result).to.deep.equal(arg); + expect((await this.context.client.complex({ complex: arg })).result).to.deep.equal(arg); }); it("complex with void", async function() { const complex = { tag: "Void", values: undefined }; const ret = { tag: "Void" }; - const { result } = await this.context.client.complex({ complex }); - expect(result).to.deep.equal(ret); + expect((await this.context.client.complex({ complex })).result).to.deep.equal(ret); }); it("addresse", async function() { - const { result } = await this.context.client.addresse({ addresse: this.context.publicKey }); - expect(result).to.equal(this.context.addr.toString()); + expect((await this.context.client.addresse({ addresse: this.context.publicKey })).result).to.equal(this.context.addr.toString()); }); it("bytes", async function() { const bytes = Buffer.from("hello"); - const { result } = await this.context.client.bytes({ bytes }); - expect(result).to.deep.equal(bytes); + expect((await this.context.client.bytes({ bytes })).result).to.deep.equal(bytes); }); it("bytesN", async function() { const bytesN = Buffer.from("123456789"); // what's the correct way to construct bytesN? - const { result } = await this.context.client.bytes_n({ bytes_n: bytesN }); - expect(result).to.deep.equal(bytesN); + expect((await this.context.client.bytes_n({ bytes_n: bytesN })).result).to.deep.equal(bytesN); }); it("card", async function() { const card = 11; - const { result } = await this.context.client.card({ card }); - expect(result).to.equal(card); + expect((await this.context.client.card({ card })).result).to.equal(card); }); it("boolean", async function() { - const { result } = await this.context.client.boolean({ boolean: true }); - expect(result).to.equal(true); + expect((await this.context.client.boolean({ boolean: true })).result).to.equal(true); }); it("not", async function() { - const { result } = await this.context.client.not({ boolean: true }); - expect(result).to.equal(false); + expect((await this.context.client.not({ boolean: true })).result).to.equal(false); }); it("i128", async function() { - const { result } = await this.context.client.i128({ i128: -1n }); - expect(result).to.equal(-1n); + expect((await this.context.client.i128({ i128: -1n })).result).to.equal(-1n); }); it("u128", async function() { - const { result } = await this.context.client.u128({ u128: 1n }); - expect(result).to.equal(1n); + expect((await this.context.client.u128({ u128: 1n })).result).to.equal(1n); }); it("multi_args", async function() { @@ -182,20 +158,17 @@ describe("Custom Types Tests", function() { const map = new Map(); map.set(1, true); map.set(2, false); - const { result } = await this.context.client.map({ map }); - expect(result).to.deep.equal(Array.from(map.entries())); + expect((await this.context.client.map({ map })).result).to.deep.equal(Array.from(map.entries())); }); it("vec", async function() { const vec = [1, 2, 3]; - const { result } = await this.context.client.vec({ vec }); - expect(result).to.deep.equal(vec); + expect((await this.context.client.vec({ vec })).result).to.deep.equal(vec); }); it("tuple", async function() { const tuple = ["hello", 1]; - const { result } = await this.context.client.tuple({ tuple }); - expect(result).to.deep.equal(tuple); + expect((await this.context.client.tuple({ tuple })).result).to.deep.equal(tuple); }); it("option", async function() { @@ -211,18 +184,15 @@ describe("Custom Types Tests", function() { }); it("u256", async function() { - const { result } = await this.context.client.u256({ u256: 1n }); - expect(result).to.equal(1n); + expect((await this.context.client.u256({ u256: 1n })).result).to.equal(1n); }); it("i256", async function() { - const { result } = await this.context.client.i256({ i256: -1n }); - expect(result).to.equal(-1n); + expect((await this.context.client.i256({ i256: -1n })).result).to.equal(-1n); }); it("string", async function() { - const { result } = await this.context.client.string({ string: "hello" }); - expect(result).to.equal("hello"); + expect((await this.context.client.string({ string: "hello" })).result).to.equal("hello"); }); it("tuple strukt", async function() { @@ -231,7 +201,6 @@ describe("Custom Types Tests", function() { { tag: "First", values: undefined }, ]; const res = [{ a: 0, b: true, c: "hello" }, { tag: "First" }]; - const result = await this.context.client.tuple_strukt({ tuple_strukt: arg }); - expect(result.result).to.deep.equal(res); + expect((await this.context.client.tuple_strukt({ tuple_strukt: arg })).result).to.deep.equal(res); }); }); \ No newline at end of file