-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat!: remove nested option size validation (#2322)
- Loading branch information
1 parent
05893a7
commit 0da455a
Showing
10 changed files
with
237 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@fuel-ts/abi-coder": minor | ||
--- | ||
|
||
feat!: remove nested option size validation |
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
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,151 @@ | ||
import type { Contract } from 'fuels'; | ||
|
||
import { getSetupContract } from './utils'; | ||
|
||
const U8_MAX = 255; | ||
const U16_MAX = 65535; | ||
const U32_MAX = 4294967295; | ||
|
||
const setupContract = getSetupContract('options'); | ||
let contractInstance: Contract; | ||
beforeAll(async () => { | ||
contractInstance = await setupContract(); | ||
}); | ||
|
||
/** | ||
* @group node | ||
*/ | ||
describe('Options Tests', () => { | ||
it('echos u8 option', async () => { | ||
const someInput = U8_MAX; | ||
const noneInput = undefined; | ||
|
||
const { value: someValue } = await contractInstance.functions.echo_option(someInput).call(); | ||
|
||
expect(someValue).toBe(someInput); | ||
|
||
const { value: noneValue } = await contractInstance.functions.echo_option(noneInput).call(); | ||
|
||
expect(noneValue).toBe(noneInput); | ||
}); | ||
|
||
it('echos struct enum option', async () => { | ||
const someInput = { | ||
one: { | ||
a: U8_MAX, | ||
}, | ||
two: U32_MAX, | ||
}; | ||
|
||
const { value: someValue } = await contractInstance.functions | ||
.echo_struct_enum_option(someInput) | ||
.call(); | ||
|
||
expect(someValue).toStrictEqual(someInput); | ||
|
||
const noneInput = { | ||
one: { | ||
a: undefined, | ||
}, | ||
two: undefined, | ||
}; | ||
|
||
const { value: noneValue } = await contractInstance.functions | ||
.echo_struct_enum_option(noneInput) | ||
.call(); | ||
|
||
expect(noneValue).toStrictEqual(noneInput); | ||
}); | ||
|
||
it('echos vec option', async () => { | ||
const someInput = [U8_MAX, U16_MAX, U32_MAX]; | ||
|
||
const { value: someValue } = await contractInstance.functions.echo_vec_option(someInput).call(); | ||
|
||
expect(someValue).toStrictEqual(someInput); | ||
|
||
const noneInput = [undefined, undefined, undefined]; | ||
|
||
const { value: noneValue } = await contractInstance.functions.echo_vec_option(noneInput).call(); | ||
|
||
expect(noneValue).toStrictEqual(noneInput); | ||
|
||
const mixedInput = [U8_MAX, undefined, U32_MAX]; | ||
|
||
const { value: mixedValue } = await contractInstance.functions | ||
.echo_vec_option(mixedInput) | ||
.call(); | ||
|
||
expect(mixedValue).toStrictEqual(mixedInput); | ||
}); | ||
|
||
it('echos tuple option', async () => { | ||
const someInput = [U8_MAX, U16_MAX]; | ||
|
||
const { value: someValue } = await contractInstance.functions | ||
.echo_tuple_option(someInput) | ||
.call(); | ||
|
||
expect(someValue).toStrictEqual(someInput); | ||
|
||
const noneInput = [undefined, undefined]; | ||
|
||
const { value: noneValue } = await contractInstance.functions | ||
.echo_tuple_option(noneInput) | ||
.call(); | ||
|
||
expect(noneValue).toStrictEqual(noneInput); | ||
|
||
const mixedInput = [U8_MAX, undefined]; | ||
|
||
const { value: mixedValue } = await contractInstance.functions | ||
.echo_tuple_option(mixedInput) | ||
.call(); | ||
|
||
expect(mixedValue).toStrictEqual(mixedInput); | ||
}); | ||
|
||
it('echoes enum option', async () => { | ||
const someInput = { a: U8_MAX }; | ||
|
||
const { value: someValue } = await contractInstance.functions | ||
.echo_enum_option(someInput) | ||
.call(); | ||
|
||
expect(someValue).toStrictEqual(someInput); | ||
|
||
const noneInput = { b: undefined }; | ||
|
||
const { value: noneValue } = await contractInstance.functions | ||
.echo_enum_option(noneInput) | ||
.call(); | ||
|
||
expect(noneValue).toStrictEqual(noneInput); | ||
}); | ||
|
||
it('echos array option', async () => { | ||
const someInput = [U8_MAX, U16_MAX, 123]; | ||
|
||
const { value: someValue } = await contractInstance.functions | ||
.echo_array_option(someInput) | ||
.call(); | ||
|
||
expect(someValue).toStrictEqual(someInput); | ||
|
||
const noneInput = [undefined, undefined, undefined]; | ||
|
||
const { value: noneValue } = await contractInstance.functions | ||
.echo_array_option(noneInput) | ||
.call(); | ||
|
||
expect(noneValue).toStrictEqual(noneInput); | ||
|
||
const mixedInput = [U8_MAX, undefined, 123]; | ||
|
||
const { value: mixedValue } = await contractInstance.functions | ||
.echo_array_option(mixedInput) | ||
.call(); | ||
|
||
expect(mixedValue).toStrictEqual(mixedInput); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -62,4 +62,5 @@ members = [ | |
"vector-types-contract", | ||
"vector-types-script", | ||
"vectors", | ||
"options", | ||
] |
7 changes: 7 additions & 0 deletions
7
packages/fuel-gauge/test/fixtures/forc-projects/options/Forc.toml
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,7 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
license = "Apache-2.0" | ||
name = "options" | ||
|
||
[dependencies] |
Oops, something went wrong.