/
bytes.test.ts
39 lines (28 loc) · 1006 Bytes
/
bytes.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import type { Contract, Bytes } from 'fuels';
import { DocSnippetProjectsEnum } from '../../../test/fixtures/forc-projects';
import { createAndDeployContractFromProject } from '../../utils';
/**
* @group node
*/
describe('Bytes', () => {
let contract: Contract;
beforeAll(async () => {
contract = await createAndDeployContractFromProject(DocSnippetProjectsEnum.ECHO_BYTES);
});
it('should pass bytes to a contract', async () => {
// #region bytes-1
// #import { Bytes };
const bytes: Bytes = [40, 41, 42];
const { value } = await contract.functions.bytes_comparison(bytes).simulate();
expect(value).toBeTruthy();
// #endregion bytes-1
});
it('should retrieve bytes from a contract', async () => {
// #region bytes-2
// #import { Bytes };
const bytes: Bytes = [8, 42, 77];
const { value } = await contract.functions.echo_bytes(bytes).simulate();
expect(value).toStrictEqual(new Uint8Array(bytes));
// #endregion bytes-2
});
});