|
1 | | -import * as anchor from '@coral-xyz/anchor'; |
2 | | -import type { Carnival } from '../target/types/carnival'; |
| 1 | +import * as anchor from "@coral-xyz/anchor"; |
| 2 | +import type { Carnival } from "../target/types/carnival.ts"; |
3 | 3 |
|
4 | | -describe('Carnival', () => { |
5 | | - const provider = anchor.AnchorProvider.env(); |
6 | | - anchor.setProvider(provider); |
7 | | - const wallet = provider.wallet as anchor.Wallet; |
8 | | - const program = anchor.workspace.Carnival as anchor.Program<Carnival>; |
| 4 | +describe("Carnival", () => { |
| 5 | + const provider = anchor.AnchorProvider.env(); |
| 6 | + anchor.setProvider(provider); |
| 7 | + const wallet = provider.wallet as anchor.Wallet; |
| 8 | + const program = anchor.workspace.Carnival as anchor.Program<Carnival>; |
9 | 9 |
|
10 | | - async function sendCarnivalInstructions(instructionsList: anchor.web3.TransactionInstruction[]) { |
11 | | - const tx = new anchor.web3.Transaction(); |
12 | | - for (const ix of instructionsList) { |
13 | | - tx.add(ix); |
14 | | - } |
15 | | - await anchor.web3.sendAndConfirmTransaction(provider.connection, tx, [wallet.payer]); |
16 | | - } |
| 10 | + async function sendCarnivalInstructions( |
| 11 | + instructionsList: anchor.web3.TransactionInstruction[], |
| 12 | + ) { |
| 13 | + const tx = new anchor.web3.Transaction(); |
| 14 | + for (const ix of instructionsList) { |
| 15 | + tx.add(ix); |
| 16 | + } |
| 17 | + await anchor.web3.sendAndConfirmTransaction(provider.connection, tx, [ |
| 18 | + wallet.payer, |
| 19 | + ]); |
| 20 | + } |
17 | 21 |
|
18 | | - it('Go on some rides!', async () => { |
19 | | - await sendCarnivalInstructions([ |
20 | | - await program.methods.goOnRide('Jimmy', 36, 15, 'Scrambler').instruction(), |
21 | | - await program.methods.goOnRide('Mary', 52, 1, 'Ferris Wheel').instruction(), |
22 | | - await program.methods.goOnRide('Alice', 56, 15, 'Scrambler').instruction(), |
23 | | - await program.methods.goOnRide('Bob', 49, 6, 'Tilt-a-Whirl').instruction(), |
24 | | - ]); |
25 | | - }); |
| 22 | + it("Go on some rides!", async () => { |
| 23 | + await sendCarnivalInstructions([ |
| 24 | + await program.methods |
| 25 | + .goOnRide("Jimmy", 36, 15, "Scrambler") |
| 26 | + .instruction(), |
| 27 | + await program.methods |
| 28 | + .goOnRide("Mary", 52, 1, "Ferris Wheel") |
| 29 | + .instruction(), |
| 30 | + await program.methods |
| 31 | + .goOnRide("Alice", 56, 15, "Scrambler") |
| 32 | + .instruction(), |
| 33 | + await program.methods |
| 34 | + .goOnRide("Bob", 49, 6, "Tilt-a-Whirl") |
| 35 | + .instruction(), |
| 36 | + ]); |
| 37 | + }); |
26 | 38 |
|
27 | | - it('Play some games!', async () => { |
28 | | - await sendCarnivalInstructions([ |
29 | | - await program.methods.playGame('Jimmy', 15, 'I Got It!').instruction(), |
30 | | - await program.methods.playGame('Mary', 1, 'Ring Toss').instruction(), |
31 | | - await program.methods.playGame('Alice', 15, 'Ladder Climb').instruction(), |
32 | | - await program.methods.playGame('Bob', 6, 'Ring Toss').instruction(), |
33 | | - ]); |
34 | | - }); |
| 39 | + it("Play some games!", async () => { |
| 40 | + await sendCarnivalInstructions([ |
| 41 | + await program.methods.playGame("Jimmy", 15, "I Got It!").instruction(), |
| 42 | + await program.methods.playGame("Mary", 1, "Ring Toss").instruction(), |
| 43 | + await program.methods.playGame("Alice", 15, "Ladder Climb").instruction(), |
| 44 | + await program.methods.playGame("Bob", 6, "Ring Toss").instruction(), |
| 45 | + ]); |
| 46 | + }); |
35 | 47 |
|
36 | | - it('Eat some food!', async () => { |
37 | | - await sendCarnivalInstructions([ |
38 | | - await program.methods.eatFood('Jimmy', 15, 'Taco Shack').instruction(), |
39 | | - await program.methods.eatFood('Mary', 1, "Larry's Pizza").instruction(), |
40 | | - await program.methods.eatFood('Alice', 15, "Dough Boy's").instruction(), |
41 | | - await program.methods.eatFood('Bob', 6, "Dough Boy's").instruction(), |
42 | | - ]); |
43 | | - }); |
| 48 | + it("Eat some food!", async () => { |
| 49 | + await sendCarnivalInstructions([ |
| 50 | + await program.methods.eatFood("Jimmy", 15, "Taco Shack").instruction(), |
| 51 | + await program.methods.eatFood("Mary", 1, "Larry's Pizza").instruction(), |
| 52 | + await program.methods.eatFood("Alice", 15, "Dough Boy's").instruction(), |
| 53 | + await program.methods.eatFood("Bob", 6, "Dough Boy's").instruction(), |
| 54 | + ]); |
| 55 | + }); |
44 | 56 | }); |
0 commit comments