Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testcase: test_big_message #9

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions tests/omni_lock_rust/tests/test_omni_lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,6 @@ fn tested_by_append_witnessed_less_than_4() {
verify_result.expect("pass verification");
}


#[test]
fn test_non_empty_witness() {
let mut data_loader = DummyDataLoader::new();
Expand Down Expand Up @@ -957,7 +956,6 @@ fn test_sighash_all_only() {
verify_result.expect("pass verification");
}


#[test]
fn tested_by_append_witnessargs() {
let mut data_loader = DummyDataLoader::new();
Expand Down Expand Up @@ -1040,7 +1038,6 @@ fn tested_by_sighashall_dup() {
verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
assert_script_error(verify_result.unwrap_err(), MOL2_ERR_OVERFLOW);
//
}

#[test]
Expand Down Expand Up @@ -1096,5 +1093,45 @@ fn tested_by_insert_witness_less_4_before_sighashall() {
verifier.set_debug_printer(debug_printer);
let verify_result = verifier.verify(MAX_CYCLES);
verify_result.unwrap_err();
//
}

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

let mut config = TestConfig::new(IDENTITY_FLAGS_BITCOIN, false);
config.cobuild_enabled = true;

let mut action_vec = Vec::<Action>::new();
for _ in 0..3072 {
let action_builder = Action::new_builder();
let action_builder = action_builder.script_info_hash(
ckb_types::packed::Byte32::new_unchecked(Bytes::from(vec![0x00; 32])),
);
let action_builder = action_builder.script_hash(ckb_types::packed::Byte32::new_unchecked(
Bytes::from(vec![0x00; 32]),
));
let action_builder = action_builder.data(ckb_types::packed::Bytes::new_unchecked(
Bytes::from(vec![0x42; 128]),
));
let action = action_builder.build();
action_vec.push(action);
}
let action_vec = ActionVec::new_builder().extend(action_vec).build();
let message = Message::new_builder().actions(action_vec).build();
config.cobuild_message = Some(message); // Message is 651300 bytes in molecule type.

config.set_chain_config(Box::new(BitcoinConfig {
sign_vtype: BITCOIN_V_TYPE_P2PKHCOMPRESSED,
pubkey_err: false,
}));

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");
}