-
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
Showing
74 changed files
with
1,054 additions
and
810 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,46 +1,48 @@ | ||
const assert = require('assert'); | ||
const anchor = require('@project-serum/anchor'); | ||
const assert = require("assert"); | ||
const anchor = require("@project-serum/anchor"); | ||
const { SystemProgram } = anchor.web3; | ||
|
||
describe('basic-2', () => { | ||
const provider = anchor.Provider.local() | ||
describe("basic-2", () => { | ||
const provider = anchor.Provider.local(); | ||
|
||
// Configure the client to use the local cluster. | ||
anchor.setProvider(provider) | ||
anchor.setProvider(provider); | ||
|
||
// Counter for the tests. | ||
const counter = anchor.web3.Keypair.generate() | ||
const counter = anchor.web3.Keypair.generate(); | ||
|
||
// Program for the tests. | ||
const program = anchor.workspace.Basic2 | ||
const program = anchor.workspace.Basic2; | ||
|
||
it('Creates a counter', async () => { | ||
it("Creates a counter", async () => { | ||
await program.rpc.create(provider.wallet.publicKey, { | ||
accounts: { | ||
counter: counter.publicKey, | ||
user: provider.wallet.publicKey, | ||
systemProgram: SystemProgram.programId, | ||
}, | ||
signers: [counter], | ||
}) | ||
}); | ||
|
||
let counterAccount = await program.account.counter.fetch(counter.publicKey) | ||
let counterAccount = await program.account.counter.fetch(counter.publicKey); | ||
|
||
assert.ok(counterAccount.authority.equals(provider.wallet.publicKey)) | ||
assert.ok(counterAccount.count.toNumber() === 0) | ||
}) | ||
assert.ok(counterAccount.authority.equals(provider.wallet.publicKey)); | ||
assert.ok(counterAccount.count.toNumber() === 0); | ||
}); | ||
|
||
it('Updates a counter', async () => { | ||
it("Updates a counter", async () => { | ||
await program.rpc.increment({ | ||
accounts: { | ||
counter: counter.publicKey, | ||
authority: provider.wallet.publicKey, | ||
}, | ||
}) | ||
}); | ||
|
||
const counterAccount = await program.account.counter.fetch(counter.publicKey) | ||
const counterAccount = await program.account.counter.fetch( | ||
counter.publicKey | ||
); | ||
|
||
assert.ok(counterAccount.authority.equals(provider.wallet.publicKey)) | ||
assert.ok(counterAccount.count.toNumber() == 1) | ||
}) | ||
}) | ||
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
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
File renamed without changes.
File renamed without changes.
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.