-
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.
Merge branch 'master' into db/feat/unsupported-blob-tx
- Loading branch information
Showing
25 changed files
with
952 additions
and
159 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,4 @@ | ||
--- | ||
--- | ||
|
||
fix: build error for `demo-wallet-sdk-react` |
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 @@ | ||
--- | ||
"create-fuels": patch | ||
--- | ||
|
||
feat: add testing to `create-fuels` |
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
65 changes: 65 additions & 0 deletions
65
apps/docs-snippets/src/guide/create-fuels/decrement_counter.test.ts
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,65 @@ | ||
import { launchTestNode } from 'fuels/test-utils'; | ||
import { describe, test, expect } from 'vitest'; | ||
|
||
import { CounterAbi__factory } from '../../../test/typegen'; | ||
import bytecode from '../../../test/typegen/contracts/CounterAbi.hex'; | ||
|
||
/** | ||
* @group node | ||
* @group browser | ||
*/ | ||
describe('Counter Contract', () => { | ||
// #region decrement-counter | ||
// #context import { CounterAbi__factory } from './sway-programs-api'; | ||
// #context import bytecode from './sway-programs-api/contracts/CounterAbi.hex'; | ||
|
||
test('calls the decrement_counter function', async () => { | ||
// First, we'll launch a test node, passing the contract factory and bytecode. This will deploy the contract | ||
// to our test node so we can test against it. | ||
using launched = await launchTestNode({ | ||
// The test node will be killed automatically once the `launched` variable goes out of scope, | ||
// because we are instantiating it with the `using` keyword. | ||
contractsConfigs: [ | ||
{ | ||
deployer: CounterAbi__factory, | ||
bytecode, | ||
}, | ||
], | ||
}); | ||
|
||
// We can now destructure the contract from the launched object. | ||
const { | ||
contracts: [contract], | ||
} = launched; | ||
|
||
// Lets setup some values to use in the test. | ||
const initialCount = 0; | ||
const incrementedValue = 5; | ||
const decrementedValue = 2; | ||
|
||
// We can now call the contract functions and test the results. Lets assert the initial value of the counter. | ||
const { waitForResult: initWaitForResult } = await contract.functions.get_count().call(); | ||
const { value: initValue } = await initWaitForResult(); | ||
expect(initValue.toNumber()).toBe(initialCount); | ||
|
||
// Next we'll increment the counter, so that we can decrement it. | ||
const { waitForResult: incWaitForResult } = await contract.functions | ||
.increment_counter(5) | ||
.call(); | ||
const { value: incValue } = await incWaitForResult(); | ||
expect(incValue.toNumber()).toBe(incrementedValue); | ||
|
||
// Next, we'll decrement the counter by 3 and assert the new value. | ||
const { waitForResult: decWaitForResult } = await contract.functions | ||
.decrement_counter(3) | ||
.call(); | ||
const { value: decValue } = await decWaitForResult(); | ||
expect(decValue.toNumber()).toBe(decrementedValue); | ||
|
||
// Finally, we'll test the get count function again to ensure parity. | ||
const { waitForResult: finalWaitForResult } = await contract.functions.get_count().call(); | ||
const { value: finalValue } = await finalWaitForResult(); | ||
expect(finalValue.toNumber()).toBe(decrementedValue); | ||
}); | ||
// #endregion decrement-counter | ||
}); |
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
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
Oops, something went wrong.