Skip to content

Commit

Permalink
Add multisig testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Jan 23, 2024
1 parent 3902b62 commit c81f235
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/omni_lock_rust/tests/test_multisig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,66 @@ fn test_multisig_0_2_3_unlock_smt_in_input() {
let verify_result = verifier.verify(MAX_CYCLES);
verify_result.expect("pass verification");
}

#[test]
fn test_cobuild_multisig_0_2_3_unlock() {
let mut data_loader = DummyDataLoader::new();

let mut config = TestConfig::new(IDENTITY_FLAGS_MULTISIG, true);
config.cobuild_enabled = true;
config.set_multisig(0, 2, 3);

config.scheme = TestScheme::OnWhiteList;

let tx = gen_tx(&mut data_loader, &mut config);
let tx = sign_tx(&mut data_loader, tx, &mut config);
let resolved_tx = build_resolved_tx(&data_loader, &tx);

let mut verifier = verify_tx(resolved_tx, data_loader);

verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
verify_result.expect("pass verification");
}

#[test]
fn test_cobuild_multisig_invalid_flags() {
let mut data_loader = DummyDataLoader::new();

let mut config = TestConfig::new(IDENTITY_FLAGS_MULTISIG, true);
config.set_multisig(0, 2, 3);
config.multisig.set(0, 2, 4);
config.cobuild_enabled = true;

config.scheme = TestScheme::OnWhiteList;

let tx = gen_tx(&mut data_loader, &mut config);
let tx = sign_tx(&mut data_loader, tx, &mut config);
let resolved_tx = build_resolved_tx(&data_loader, &tx);

let mut verifier = verify_tx(resolved_tx, data_loader);
verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
assert_script_error(verify_result.unwrap_err(), ERROR_MULTSIG_SCRIPT_HASH)
}

#[test]
fn test_cobuild_multisig_invalid_flags2() {
let mut data_loader = DummyDataLoader::new();

let mut config = TestConfig::new(IDENTITY_FLAGS_MULTISIG, true);
config.set_multisig(0, 2, 3);
config.multisig.set(0, 3, 3);
config.cobuild_enabled = true;

config.scheme = TestScheme::OnWhiteList;

let tx = gen_tx(&mut data_loader, &mut config);
let tx = sign_tx(&mut data_loader, tx, &mut config);
let resolved_tx = build_resolved_tx(&data_loader, &tx);

let mut verifier = verify_tx(resolved_tx, data_loader);
verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
assert_script_error(verify_result.unwrap_err(), ERROR_MULTSIG_SCRIPT_HASH)
}

0 comments on commit c81f235

Please sign in to comment.