Skip to content

Commit

Permalink
validate that offchain version is not 0 (#111)
Browse files Browse the repository at this point in the history
aalu1418 authored Jan 14, 2022
1 parent 81e4110 commit fd9d901
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions contracts/programs/ocr2/src/lib.rs
Original file line number Diff line number Diff line change
@@ -99,6 +99,7 @@ pub mod ocr2 {
// disallow begin if we already started writing
require!(config.pending_offchain_config.version == 0, InvalidInput);
require!(config.pending_offchain_config.is_empty(), InvalidInput);
require!(offchain_config_version != 0, InvalidInput);

config.pending_offchain_config.version = offchain_config_version;
Ok(())
16 changes: 16 additions & 0 deletions contracts/tests/ocr2.spec.ts
Original file line number Diff line number Diff line change
@@ -426,6 +426,22 @@ describe('ocr2', async () => {
});
});

it("Can't begin offchain config if version is 0", async () => {
try {
await program.rpc.beginOffchainConfig(
new BN(0),
{
accounts: {
state: state.publicKey,
authority: owner.publicKey,
},
});
assert.fail("beginOffchainConfig shouldn't have succeeded!")
} catch {
// beginOffchainConfig should fail
}
});

it("Can't transmit a round if not the writer", async () => {
try {
await transmit(1, 1, new BN(1));

0 comments on commit fd9d901

Please sign in to comment.