@@ -3,145 +3,142 @@ const anchor = require("@anchor-lang/core");
33describe ( "tictactoe" , ( ) => {
44 anchor . setProvider ( anchor . AnchorProvider . env ( ) ) ;
55 const program = anchor . workspace . Tictactoe ;
6- let dashboard = anchor . web3 . Keypair . generate ( ) ;
7- let game = anchor . web3 . Keypair . generate ( ) ;
8- let player_o = anchor . web3 . Keypair . generate ( ) ;
6+
7+ const dashboard = anchor . web3 . Keypair . generate ( ) ;
8+ const game = anchor . web3 . Keypair . generate ( ) ;
9+ const playerO = anchor . web3 . Keypair . generate ( ) ;
10+ const playerX = program . provider . wallet ;
911
1012 it ( "Initialize Dashboard" , async ( ) => {
1113 const tx = await program . rpc . initializeDashboard ( {
1214 accounts : {
13- authority : program . provider . wallet . publicKey ,
15+ authority : playerX . publicKey ,
1416 dashboard : dashboard . publicKey ,
15- rent : anchor . web3 . SYSVAR_RENT_PUBKEY ,
1617 } ,
1718 signers : [ dashboard ] ,
1819 instructions : [
1920 await program . account . dashboard . createInstruction ( dashboard ) ,
2021 ] ,
2122 } ) ;
22-
23- console . log ( "transaction: " , tx ) ;
23+ console . log ( "transaction:" , tx ) ;
2424 } ) ;
2525
2626 it ( "Initialize Game" , async ( ) => {
2727 const tx = await program . rpc . initialize ( {
2828 accounts : {
29- playerX : program . provider . wallet . publicKey ,
29+ playerX : playerX . publicKey ,
3030 dashboard : dashboard . publicKey ,
3131 game : game . publicKey ,
32- rent : anchor . web3 . SYSVAR_RENT_PUBKEY ,
3332 } ,
3433 signers : [ game ] ,
3534 instructions : [ await program . account . game . createInstruction ( game ) ] ,
3635 } ) ;
37-
38- console . log ( "transaction: " , tx ) ;
36+ console . log ( "transaction:" , tx ) ;
3937 } ) ;
4038
4139 it ( "Player O joins" , async ( ) => {
4240 const tx = await program . rpc . playerJoin ( {
4341 accounts : {
44- playerO : player_o . publicKey ,
42+ playerO : playerO . publicKey ,
4543 game : game . publicKey ,
4644 } ,
47- signers : [ player_o ] ,
45+ signers : [ playerO ] ,
4846 } ) ;
49-
50- console . log ( "transaction: " , tx ) ;
47+ console . log ( "transaction:" , tx ) ;
5148 } ) ;
5249
53- it ( "Player x plays" , async ( ) => {
50+ it ( "Player X plays" , async ( ) => {
5451 const tx = await program . rpc . playerMove ( 1 , 0 , {
5552 accounts : {
56- player : program . provider . wallet . publicKey ,
53+ player : playerX . publicKey ,
5754 game : game . publicKey ,
5855 } ,
5956 } ) ;
60- console . log ( "transaction: " , tx ) ;
57+ console . log ( "transaction:" , tx ) ;
6158 } ) ;
6259
63- it ( "Player o plays" , async ( ) => {
60+ it ( "Player O plays" , async ( ) => {
6461 const tx = await program . rpc . playerMove ( 2 , 1 , {
6562 accounts : {
66- player : player_o . publicKey ,
63+ player : playerO . publicKey ,
6764 game : game . publicKey ,
6865 } ,
69- signers : [ player_o ] ,
66+ signers : [ playerO ] ,
7067 } ) ;
71- console . log ( "transaction: " , tx ) ;
68+ console . log ( "transaction:" , tx ) ;
7269 } ) ;
7370
74- it ( "Player x plays" , async ( ) => {
71+ it ( "Player X plays" , async ( ) => {
7572 const tx = await program . rpc . playerMove ( 1 , 3 , {
7673 accounts : {
77- player : program . provider . wallet . publicKey ,
74+ player : playerX . publicKey ,
7875 game : game . publicKey ,
7976 } ,
8077 } ) ;
81- console . log ( "transaction: " , tx ) ;
78+ console . log ( "transaction:" , tx ) ;
8279 } ) ;
8380
84- it ( "Player o plays" , async ( ) => {
81+ it ( "Player O plays" , async ( ) => {
8582 const tx = await program . rpc . playerMove ( 2 , 6 , {
8683 accounts : {
87- player : player_o . publicKey ,
84+ player : playerO . publicKey ,
8885 game : game . publicKey ,
8986 } ,
90- signers : [ player_o ] ,
87+ signers : [ playerO ] ,
9188 } ) ;
92- console . log ( "transaction: " , tx ) ;
89+ console . log ( "transaction:" , tx ) ;
9390 } ) ;
9491
95- it ( "Player x plays" , async ( ) => {
92+ it ( "Player X plays" , async ( ) => {
9693 const tx = await program . rpc . playerMove ( 1 , 2 , {
9794 accounts : {
98- player : program . provider . wallet . publicKey ,
95+ player : playerX . publicKey ,
9996 game : game . publicKey ,
10097 } ,
10198 } ) ;
102- console . log ( "transaction: " , tx ) ;
99+ console . log ( "transaction:" , tx ) ;
103100 } ) ;
104101
105- it ( "Player o plays" , async ( ) => {
102+ it ( "Player O plays" , async ( ) => {
106103 const tx = await program . rpc . playerMove ( 2 , 4 , {
107104 accounts : {
108- player : player_o . publicKey ,
105+ player : playerO . publicKey ,
109106 game : game . publicKey ,
110107 } ,
111- signers : [ player_o ] ,
108+ signers : [ playerO ] ,
112109 } ) ;
113- console . log ( "transaction: " , tx ) ;
110+ console . log ( "transaction:" , tx ) ;
114111 } ) ;
115112
116- it ( "Player x plays" , async ( ) => {
113+ it ( "Player X plays" , async ( ) => {
117114 const tx = await program . rpc . playerMove ( 1 , 5 , {
118115 accounts : {
119- player : program . provider . wallet . publicKey ,
116+ player : playerX . publicKey ,
120117 game : game . publicKey ,
121118 } ,
122119 } ) ;
123- console . log ( "transaction: " , tx ) ;
120+ console . log ( "transaction:" , tx ) ;
124121 } ) ;
125122
126- it ( "Player o plays" , async ( ) => {
123+ it ( "Player O plays" , async ( ) => {
127124 const tx = await program . rpc . playerMove ( 2 , 8 , {
128125 accounts : {
129- player : player_o . publicKey ,
126+ player : playerO . publicKey ,
130127 game : game . publicKey ,
131128 } ,
132- signers : [ player_o ] ,
129+ signers : [ playerO ] ,
133130 } ) ;
134- console . log ( "transaction: " , tx ) ;
131+ console . log ( "transaction:" , tx ) ;
135132 } ) ;
136133
137- it ( "Player x plays" , async ( ) => {
134+ it ( "Player X plays" , async ( ) => {
138135 const tx = await program . rpc . playerMove ( 1 , 7 , {
139136 accounts : {
140- player : program . provider . wallet . publicKey ,
137+ player : playerX . publicKey ,
141138 game : game . publicKey ,
142139 } ,
143140 } ) ;
144- console . log ( "transaction: " , tx ) ;
141+ console . log ( "transaction:" , tx ) ;
145142 } ) ;
146143
147144 it ( "Status" , async ( ) => {
@@ -151,7 +148,6 @@ describe("tictactoe", () => {
151148 game : game . publicKey ,
152149 } ,
153150 } ) ;
154-
155- console . log ( "transaction: " , tx ) ;
151+ console . log ( "transaction:" , tx ) ;
156152 } ) ;
157153} ) ;
0 commit comments