Skip to content

Commit 5075d5f

Browse files
authored
Merge pull request solana-labs#64 from jarry-xiao/gumball-machine
Gumball machine v0
2 parents 394e15e + 2b19881 commit 5075d5f

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

contracts/tests/gummyroll-test.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import {
2121
decodeMerkleRoll,
2222
getMerkleRollAccountSize,
2323
createVerifyLeafIx,
24+
assertOnChainMerkleRollProperties
2425
} from '../sdk/gummyroll';
2526
import { execute } from "./utils";
27+
import NodeWallet from "@project-serum/anchor/dist/cjs/nodewallet";
2628

2729
// @ts-ignore
2830
let Gummyroll;
@@ -114,31 +116,8 @@ describe("gummyroll", () => {
114116
await Gummyroll.provider.send(tx, [payer, merkleRollKeypair], {
115117
commitment: "confirmed",
116118
});
117-
const merkleRoll = await Gummyroll.provider.connection.getAccountInfo(
118-
merkleRollKeypair.publicKey
119-
);
120-
121-
let onChainMerkle = decodeMerkleRoll(merkleRoll.data);
122-
123-
// Check header bytes are set correctly
124-
assert(
125-
onChainMerkle.header.maxDepth === maxDepth,
126-
`Max depth does not match ${onChainMerkle.header.maxDepth}, expected ${maxDepth}`
127-
);
128-
assert(
129-
onChainMerkle.header.maxBufferSize === maxSize,
130-
`Max buffer size does not match ${onChainMerkle.header.maxBufferSize}, expected ${maxSize}`
131-
);
132-
133-
assert(
134-
onChainMerkle.header.authority.equals(payer.publicKey),
135-
"Failed to write auth pubkey"
136-
);
137-
138-
assert(
139-
onChainMerkle.roll.changeLogs[0].root.equals(new PublicKey(tree.root)),
140-
"On chain root does not match root passed in instruction"
141-
);
119+
120+
await assertOnChainMerkleRollProperties(Gummyroll.provider.connection, maxDepth, maxSize, payer.publicKey, new PublicKey(tree.root), merkleRollKeypair.publicKey);
142121

143122
return [merkleRollKeypair, tree]
144123
}

0 commit comments

Comments
 (0)