Skip to content

Commit c561884

Browse files
restore original ts test formatting
1 parent 8e21301 commit c561884

1 file changed

Lines changed: 155 additions & 191 deletions

File tree

Lines changed: 155 additions & 191 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import test from "ava";
2-
import { root, rpcUrl, signer } from "./util.js";
3-
import {
4-
Client,
5-
networks,
6-
contract as ContractClient,
7-
} from "test-custom-types";
1+
import test from 'ava'
2+
import { root, rpcUrl, signer } from './util.js'
3+
import { Client, networks, contract as ContractClient } from 'test-custom-types'
84

95
const publicKey = root.keypair.publicKey();
106

@@ -16,214 +12,182 @@ const contract = new Client({
1612
...signer,
1713
});
1814

19-
test("hello", async (t) => {
20-
const { result } = await contract.hello({ hello: "tests" });
21-
t.is(result, "tests");
22-
});
15+
test('hello', async t => {
16+
const { result } = await contract.hello({ hello: 'tests' })
17+
t.is(result, 'tests')
18+
})
2319

24-
test("woid", async (t) => {
25-
t.is((await contract.woid()).result, null);
26-
});
20+
test('woid', async t => {
21+
t.is((await contract.woid()).result, null)
22+
})
2723

28-
test("u32_fail_on_even", async (t) => {
24+
test('u32_fail_on_even', async t => {
2925
t.deepEqual(
3026
(await contract.u32_fail_on_even({ u32_: 1 })).result,
31-
new ContractClient.Ok(1),
32-
);
27+
new ContractClient.Ok(1)
28+
)
3329
t.deepEqual(
3430
(await contract.u32_fail_on_even({ u32_: 0 })).result,
35-
new ContractClient.Err({ message: "Please provide an odd number" }),
36-
);
37-
});
31+
new ContractClient.Err({ message: "Please provide an odd number" })
32+
)
33+
})
3834

39-
test("u32_", async (t) => {
40-
t.is((await contract.u32_({ u32_: 1 })).result, 1);
41-
});
35+
test('u32_', async t => {
36+
t.is((await contract.u32_({ u32_: 1 })).result, 1)
37+
})
4238

43-
test("i32_", async (t) => {
44-
t.is((await contract.i32_({ i32_: 1 })).result, 1);
45-
});
39+
test('i32_', async t => {
40+
t.is((await contract.i32_({ i32_: 1 })).result, 1)
41+
})
4642

47-
test("i64_", async (t) => {
48-
t.is((await contract.i64_({ i64_: 1n })).result, 1n);
49-
});
43+
test('i64_', async t => {
44+
t.is((await contract.i64_({ i64_: 1n })).result, 1n)
45+
})
5046

5147
test("strukt_hel", async (t) => {
52-
const test = { a: 0, b: true, c: "world" };
53-
t.deepEqual((await contract.strukt_hel({ strukt: test })).result, [
54-
"Hello",
55-
"world",
56-
]);
57-
});
48+
const test = { a: 0, b: true, c: "world" }
49+
t.deepEqual((await contract.strukt_hel({ strukt: test })).result, ["Hello", "world"])
50+
})
5851

5952
test("strukt", async (t) => {
60-
const test = { a: 0, b: true, c: "hello" };
61-
t.deepEqual((await contract.strukt({ strukt: test })).result, test);
62-
});
63-
64-
test("simple first", async (t) => {
65-
const arg = { tag: "First", values: undefined } as const;
66-
const ret = { tag: "First" };
67-
t.deepEqual((await contract.simple({ simple: arg })).result, ret);
68-
});
69-
70-
test("simple second", async (t) => {
71-
const arg = { tag: "Second", values: undefined } as const;
72-
const ret = { tag: "Second" };
73-
t.deepEqual((await contract.simple({ simple: arg })).result, ret);
74-
});
75-
76-
test("simple third", async (t) => {
77-
const arg = { tag: "Third", values: undefined } as const;
78-
const ret = { tag: "Third" };
79-
t.deepEqual((await contract.simple({ simple: arg })).result, ret);
80-
});
81-
82-
test("complex with struct", async (t) => {
83-
const arg = {
84-
tag: "Struct",
85-
values: [{ a: 0, b: true, c: "hello" }],
86-
} as const;
87-
const ret = { tag: "Struct", values: [{ a: 0, b: true, c: "hello" }] };
88-
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
89-
});
90-
91-
test("complex with tuple", async (t) => {
92-
const arg = {
93-
tag: "Tuple",
94-
values: [
95-
[
96-
{ a: 0, b: true, c: "hello" },
97-
{ tag: "First", values: undefined },
98-
],
99-
],
100-
} as const;
101-
const ret = {
102-
tag: "Tuple",
103-
values: [[{ a: 0, b: true, c: "hello" }, { tag: "First" }]],
104-
};
105-
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
106-
});
107-
108-
test("complex with enum", async (t) => {
109-
const arg = {
110-
tag: "Enum",
111-
values: [{ tag: "First", values: undefined }],
112-
} as const;
113-
const ret = { tag: "Enum", values: [{ tag: "First" }] };
114-
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
115-
});
116-
117-
test("complex with asset", async (t) => {
118-
const arg = { tag: "Asset", values: [publicKey, 1n] } as const;
119-
const ret = { tag: "Asset", values: [publicKey, 1n] };
120-
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
121-
});
122-
123-
test("complex with void", async (t) => {
124-
const arg = { tag: "Void", values: undefined } as const;
125-
const ret = { tag: "Void" };
126-
t.deepEqual((await contract.complex({ complex: arg })).result, ret);
127-
});
128-
129-
test("addresse", async (t) => {
130-
t.deepEqual(
131-
(await contract.addresse({ addresse: publicKey })).result,
132-
publicKey,
133-
);
134-
});
135-
136-
test("bytes", async (t) => {
137-
const bytes = Buffer.from("hello");
138-
t.deepEqual((await contract.bytes({ bytes })).result, bytes);
139-
});
140-
141-
test("bytes_n", async (t) => {
142-
const bytes_n = Buffer.from("123456789"); // what's the correct way to construct bytes_n?
143-
t.deepEqual((await contract.bytes_n({ bytes_n })).result, bytes_n);
144-
});
145-
146-
test("card", async (t) => {
147-
const card = 11;
148-
t.is((await contract.card({ card })).result, card);
149-
});
150-
151-
test("boolean", async (t) => {
152-
t.is((await contract.boolean({ boolean: true })).result, true);
153-
});
154-
155-
test("not", async (t) => {
156-
t.is((await contract.not({ boolean: true })).result, false);
157-
});
158-
159-
test("i128", async (t) => {
160-
t.is((await contract.i128({ i128: -1n })).result, -1n);
161-
});
162-
163-
test("u128", async (t) => {
164-
t.is((await contract.u128({ u128: 1n })).result, 1n);
165-
});
166-
167-
test("multi_args", async (t) => {
168-
t.is((await contract.multi_args({ a: 1, b: true })).result, 1);
169-
t.is((await contract.multi_args({ a: 1, b: false })).result, 0);
170-
});
171-
172-
test("map", async (t) => {
173-
const map = new Map();
174-
map.set(1, true);
175-
map.set(2, false);
53+
const test = { a: 0, b: true, c: "hello" }
54+
t.deepEqual((await contract.strukt({ strukt: test })).result, test)
55+
})
56+
57+
test('simple first', async t => {
58+
const arg = { tag: 'First', values: undefined } as const
59+
const ret = { tag: 'First' }
60+
t.deepEqual((await contract.simple({ simple: arg })).result, ret)
61+
})
62+
63+
test('simple second', async t => {
64+
const arg = { tag: 'Second', values: undefined } as const
65+
const ret = { tag: 'Second' }
66+
t.deepEqual((await contract.simple({ simple: arg })).result, ret)
67+
})
68+
69+
test('simple third', async t => {
70+
const arg = { tag: 'Third', values: undefined } as const
71+
const ret = { tag: 'Third' }
72+
t.deepEqual((await contract.simple({ simple: arg })).result, ret)
73+
})
74+
75+
test('complex with struct', async t => {
76+
const arg = { tag: 'Struct', values: [{ a: 0, b: true, c: 'hello' }] } as const
77+
const ret = { tag: 'Struct', values: [{ a: 0, b: true, c: 'hello' }] }
78+
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
79+
})
80+
81+
test('complex with tuple', async t => {
82+
const arg = { tag: 'Tuple', values: [[{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }]] } as const
83+
const ret = { tag: 'Tuple', values: [[{ a: 0, b: true, c: 'hello' }, { tag: 'First' }]] }
84+
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
85+
})
86+
87+
test('complex with enum', async t => {
88+
const arg = { tag: 'Enum', values: [{ tag: 'First', values: undefined }] } as const
89+
const ret = { tag: 'Enum', values: [{ tag: 'First' }] }
90+
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
91+
})
92+
93+
test('complex with asset', async t => {
94+
const arg = { tag: 'Asset', values: [publicKey, 1n] } as const
95+
const ret = { tag: 'Asset', values: [publicKey, 1n] }
96+
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
97+
})
98+
99+
test('complex with void', async t => {
100+
const arg = { tag: 'Void', values: undefined } as const
101+
const ret = { tag: 'Void' }
102+
t.deepEqual((await contract.complex({ complex: arg })).result, ret)
103+
})
104+
105+
test('addresse', async t => {
106+
t.deepEqual((await contract.addresse({ addresse: publicKey })).result, publicKey)
107+
})
108+
109+
test('bytes', async t => {
110+
const bytes = Buffer.from('hello')
111+
t.deepEqual((await contract.bytes({ bytes })).result, bytes)
112+
})
113+
114+
test('bytes_n', async t => {
115+
const bytes_n = Buffer.from('123456789') // what's the correct way to construct bytes_n?
116+
t.deepEqual((await contract.bytes_n({ bytes_n })).result, bytes_n)
117+
})
118+
119+
test('card', async t => {
120+
const card = 11
121+
t.is((await contract.card({ card })).result, card)
122+
})
123+
124+
test('boolean', async t => {
125+
t.is((await contract.boolean({ boolean: true })).result, true)
126+
})
127+
128+
test('not', async t => {
129+
t.is((await contract.not({ boolean: true })).result, false)
130+
})
131+
132+
test('i128', async t => {
133+
t.is((await contract.i128({ i128: -1n })).result, -1n)
134+
})
135+
136+
test('u128', async t => {
137+
t.is((await contract.u128({ u128: 1n })).result, 1n)
138+
})
139+
140+
test('multi_args', async t => {
141+
t.is((await contract.multi_args({ a: 1, b: true })).result, 1)
142+
t.is((await contract.multi_args({ a: 1, b: false })).result, 0)
143+
})
144+
145+
test('map', async t => {
146+
const map = new Map()
147+
map.set(1, true)
148+
map.set(2, false)
176149
// map.set(3, 'hahaha') // should throw an error
177-
const ret = Array.from(map.entries());
178-
t.deepEqual((await contract.map({ map })).result, ret);
179-
});
150+
const ret = Array.from(map.entries())
151+
t.deepEqual((await contract.map({ map })).result, ret)
152+
})
180153

181-
test("vec", async (t) => {
182-
const vec = [1, 2, 3];
183-
t.deepEqual((await contract.vec({ vec })).result, vec);
184-
});
154+
test('vec', async t => {
155+
const vec = [1, 2, 3]
156+
t.deepEqual((await contract.vec({ vec })).result, vec)
157+
})
185158

186-
test("tuple", async (t) => {
187-
const tuple = ["hello", 1] as const;
188-
t.deepEqual((await contract.tuple({ tuple })).result, tuple);
189-
});
159+
test('tuple', async t => {
160+
const tuple = ['hello', 1] as const
161+
t.deepEqual((await contract.tuple({ tuple })).result, tuple)
162+
})
190163

191-
test("option", async (t) => {
192-
t.deepEqual((await contract.option({ option: 1 })).result, 1);
164+
test('option', async t => {
165+
// this makes sense
166+
t.deepEqual((await contract.option({ option: 1 })).result, 1)
193167

194-
t.deepEqual((await contract.option({ option: undefined })).result, null);
168+
// this passes but shouldn't
169+
t.deepEqual((await contract.option({ option: undefined })).result, undefined)
195170

196171
// this is the behavior we probably want, but fails
197172
// t.deepEqual(await contract.option(), undefined) // typing and implementation require the object
198173
// t.deepEqual((await contract.option({})).result, undefined) // typing requires argument; implementation would be fine with this
199174
// t.deepEqual((await contract.option({ option: undefined })).result, undefined)
200-
});
201-
202-
test("u256", async (t) => {
203-
t.is((await contract.u256({ u256: 1n })).result, 1n);
204-
});
175+
})
205176

206-
test("i256", async (t) => {
207-
t.is((await contract.i256({ i256: -1n })).result, -1n);
208-
});
177+
test('u256', async t => {
178+
t.is((await contract.u256({ u256: 1n })).result, 1n)
179+
})
209180

210-
test("string", async (t) => {
211-
t.is((await contract.string({ string: "hello" })).result, "hello");
212-
});
181+
test('i256', async t => {
182+
t.is((await contract.i256({ i256: -1n })).result, -1n)
183+
})
213184

214-
test("tuple_strukt", async (t) => {
215-
const arg = [
216-
{ a: 0, b: true, c: "hello" },
217-
{ tag: "First", values: undefined },
218-
] as const;
219-
const res = [{ a: 0, b: true, c: "hello" }, { tag: "First" }];
220-
t.deepEqual((await contract.tuple_strukt({ tuple_strukt: arg })).result, res);
221-
});
185+
test('string', async t => {
186+
t.is((await contract.string({ string: 'hello' })).result, 'hello')
187+
})
222188

223-
test("timepoint", async (t) => {
224-
t.is((await contract.timepoint({ timepoint: 1n })).result, 1n);
225-
});
226-
227-
test("duration", async (t) => {
228-
t.is((await contract.duration({ duration: 1n })).result, 1n);
229-
});
189+
test('tuple_strukt', async t => {
190+
const arg = [{ a: 0, b: true, c: 'hello' }, { tag: 'First', values: undefined }] as const
191+
const res = [{ a: 0, b: true, c: 'hello' }, { tag: 'First' }]
192+
t.deepEqual((await contract.tuple_strukt({ tuple_strukt: arg })).result, res)
193+
})

0 commit comments

Comments
 (0)