-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0d7425b
commit 7b69e0b
Showing
8 changed files
with
159 additions
and
61 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
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,25 @@ | ||
{ | ||
"name": "basic-2", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"directories": { | ||
"test": "tests" | ||
}, | ||
"scripts": { | ||
"test": "ts-mocha -t 100000 -p ./tsconfig.json tests/**/*.{j,t}s" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@project-serum/anchor": "^0.2.2-beta.1", | ||
"@types/chai": "^4.2.15" | ||
}, | ||
"devDependencies": { | ||
"@types/expect": "^24.3.0", | ||
"@types/jest": "^26.0.20", | ||
"@types/mocha": "^8.2.1", | ||
"@types/node": "^14.14.31", | ||
"chai": "^4.3.0" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,44 @@ | ||
import assert from 'assert' | ||
import * as anchor from '@project-serum/anchor' | ||
describe('basic-2', () => { | ||
const provider = anchor.Provider.local() | ||
|
||
// Configure the client to use the local cluster. | ||
anchor.setProvider(provider) | ||
|
||
// Counter for the tests. | ||
const counter = new anchor.web3.Account() | ||
|
||
// Program for the tests. | ||
const program = anchor.workspace.Basic2 | ||
|
||
it('Creates a counter', async () => { | ||
await program.rpc.create(provider.wallet.publicKey, { | ||
accounts: { | ||
counter: counter.publicKey, | ||
rent: anchor.web3.SYSVAR_RENT_PUBKEY, | ||
}, | ||
signers: [counter], | ||
instructions: [await program.account.counter.createInstruction(counter)], | ||
}) | ||
|
||
let counterAccount = await program.account.counter(counter.publicKey) | ||
|
||
assert.ok(counterAccount.authority.equals(provider.wallet.publicKey)) | ||
assert.ok(counterAccount.count.toNumber() === 0) | ||
}) | ||
|
||
it('Updates a counter', async () => { | ||
await program.rpc.increment({ | ||
accounts: { | ||
counter: counter.publicKey, | ||
authority: provider.wallet.publicKey, | ||
}, | ||
}) | ||
|
||
const counterAccount = await program.account.counter(counter.publicKey) | ||
|
||
assert.ok(counterAccount.authority.equals(provider.wallet.publicKey)) | ||
assert.ok(counterAccount.count.toNumber() == 1) | ||
}) | ||
}) |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": ["mocha", "chai"], | ||
"typeRoots": ["./node_modules/@types"], | ||
"lib": ["es2015"], | ||
"module": "commonjs", | ||
"target": "es6", | ||
"esModuleInterop": true | ||
} | ||
} |