Closed ananas-block closed 1 year ago
do you suggest breaking down the function simulate inside the test?
I would just do it like this it is not very long
it('Prove hit/ miss for 32 turns', async () => {
for (let i = 1; i <= 16; i++) {
printLog(`Bob reporting result of Alice shot #${player1_nonce - 1} (Turn ${player1_nonce * 2 - 1})`)
/// BOB PROVES ALICE PREVIOUS REGISTERED SHOT HIT ///
// bob's shot hit/miss integrity proof public / private inputs
let bob_turn = await joiner.turnData(
1, // gameID
1, // _hit
shots.player2[player1_nonce - 1], // next shot from bob to alice
shots.player1[player1_nonce - 1] // alice shot to verify
);
// prove alice's registered shot hit, and register bob's next shot
await game.turn(bob_turn);
/// ALICE PROVES BOB PREV REGISTERED SHOT MISSED ///
printLog(`Alice reporting result of Bob shot #${player1_nonce - 1} (Turn ${player1_nonce * 2})`)
// bob's shot hit/miss integrity proof public / private inputs
let alice_turn = await host.turnData(
1, // gameID
0, // _hit
shots.player1[player1_nonce], // next shot from alice to bob
shots.player2[player1_nonce - 1] // bob shot to verify
);
// prove bob's registered shot missed, and register alice's next shot
await game.turn(alice_turn);
}
})
just open up the function to the test case, it is just used once so it makes sense
I know, I still don't like it
for me it makes the test a lot more difficult to read
https://github.com/Shigoto-dev19/ZK-Battleships-Solana/blob/6653dee2976ecbdcff0a48529c79a9b5dd4e7685/test/game.test.ts#L106
Your file is just 100 lines long, why nest this test?
It is a lot worse for readability and just another 100 lines