Skip to content

Commit

Permalink
chore: test min_payment and re-deploy contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
liyukun committed Jan 17, 2024
1 parent d54708f commit 604d430
Show file tree
Hide file tree
Showing 12 changed files with 79 additions and 71 deletions.
13 changes: 0 additions & 13 deletions deployment/migration/cluster/2024-01-17-063031.json

This file was deleted.

13 changes: 13 additions & 0 deletions deployment/migration/cluster/2024-01-17-080846.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster",
"tx_hash": "0x4072aa8ef8794cc8e70ae57c1dd29d2a343bc7f0cd6b13ce30ae6cd7d5b6a7d9",
"index": 0,
"occupied_capacity": 4697400000000,
"data_hash": "0x372b7c11d7b688e02d9c2b7604fbdf0dc898a0f6741854ea6c65d41f8ef4a64e",
"type_id": "0xe6023cfda763eca8a1acdd18290a5fa6b8d8bbcdb77bc185872f059441794aa0"
}
],
"dep_group_recipes": []
}
13 changes: 0 additions & 13 deletions deployment/migration/cluster_agent/2024-01-17-063159.json

This file was deleted.

13 changes: 13 additions & 0 deletions deployment/migration/cluster_agent/2024-01-17-081009.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster_agent",
"tx_hash": "0x4951fba8ae56d10c409221e412b5b5457da8b23e92b1fab8c627f609a4f53929",
"index": 0,
"occupied_capacity": 5310200000000,
"data_hash": "0xa170fc93235213e90214e4273bb283e7979bf6477f70b4f2319d3777ec36235c",
"type_id": "0xbd205fcbe1438115dbc34ba44eb8dbc03d6880037388d22f781134ce5519d771"
}
],
"dep_group_recipes": []
}
13 changes: 0 additions & 13 deletions deployment/migration/cluster_proxy/2024-01-17-063116.json

This file was deleted.

13 changes: 13 additions & 0 deletions deployment/migration/cluster_proxy/2024-01-17-080920.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "cluster_proxy",
"tx_hash": "0xbb0960de5c1960b57babd4cf4f468ac27572d24ef51dba8a2719f31dcebbc88f",
"index": 0,
"occupied_capacity": 4636600000000,
"data_hash": "0xfc1fbe95e7fb5be520f1adb2bdbd1529422613b02254ff01fd0f30604861ae36",
"type_id": "0x084539191561d1d04ea07640d9d34fbffb863814519fdb8358c534f7e0244968"
}
],
"dep_group_recipes": []
}
13 changes: 0 additions & 13 deletions deployment/migration/spore/2024-01-17-062908.json

This file was deleted.

13 changes: 13 additions & 0 deletions deployment/migration/spore/2024-01-17-080725.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cell_recipes": [
{
"name": "spore",
"tx_hash": "0x4d75c3201b06d9d4e4058468abb2b5d9aebacd4b065f6a855b4cbc2f23dfb87f",
"index": 0,
"occupied_capacity": 7409400000000,
"data_hash": "0xfd2dc714c4d4cb81e8621e5c124465a048d06551b467f58eaa64041dd322cf81",
"type_id": "0xa83025cb568121357cce0b980b757fdc935d88714db01a048af933be41f6e0e5"
}
],
"dep_group_recipes": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"cell_recipes": [
{
"name": "spore_extension_lua",
"tx_hash": "0x78018e4294ad775254a79974afd430f57b74c8bd48eb690d400b3268838b1dcf",
"tx_hash": "0xc4a70f8569649f63ca96ca8d2863f57403d5a6bf03c0b831b6400d0e5dc7dc36",
"index": 0,
"occupied_capacity": 3155000000000,
"data_hash": "0x3d24df661a87f65574eea63d7424e2bf978c498800a671dee63614dc7d473289",
"data_hash": "0x94a9b875911ace20f1f0d063a26495d14e4b04e32fd218261bb747f34e71ae47",
"type_id": "0x32f1cf61bc9747afd2f8ae4955e3f8bf80e2eb9d822d02e8561842f2cdb87930"
}
],
Expand Down
30 changes: 14 additions & 16 deletions tests/src/tests/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,15 @@ fn test_cluster_agent_mint() {
build_spore_contract_materials(&mut context, "cluster");
let cluster_id = build_type_id(&input_cell, 0);
let cluster_type =
build_spore_type_script(&mut context, &cluster_out_point, cluster_id.to_vec().into());
build_spore_type_script_with_payment(&mut context, &cluster_out_point, &cluster_id, 1);
let cluster_dep = build_normal_cell_dep(&mut context, cluster.as_slice(), cluster_type);

// proxy
let (proxy_out_point, proxy_script_dep) =
build_spore_contract_materials(&mut context, "cluster_proxy");
let proxy_id = build_type_id(&input_cell, 1);
let proxy_type_arg = vec![proxy_id.to_vec(), vec![1]].concat();
let proxy_type = build_spore_type_script(
&mut context,
&proxy_out_point,
proxy_type_arg.clone().into(),
);
let proxy_type =
build_spore_type_script_with_payment(&mut context, &proxy_out_point, &proxy_id, 1);
let proxy_dep = build_normal_cell_dep(&mut context, &cluster_id, proxy_type.clone());
let proxy_type_hash = proxy_type.unwrap_or_default().calc_script_hash();

Expand Down Expand Up @@ -242,19 +238,21 @@ mod cluster_agent_transfer {
// agent in Input
let old_cluster_id = build_type_id(&input_cell, 0);
let old_agent_data = blake2b_256("12345676890");
let old_agent_type = build_spore_type_script(
let old_agent_type = build_spore_type_script_with_payment(
&mut context,
&agent_out_point,
old_cluster_id.to_vec().into(),
&old_cluster_id,
1,
);
let old_agent_cell = build_agent_proxy_input(&mut context, &old_agent_data, old_agent_type);

// agent in Output
let new_cluster_id = build_type_id(&input_cell, new_cluster_out_index);
let new_agent_type = build_spore_type_script(
let new_agent_type = build_spore_type_script_with_payment(
&mut context,
&agent_out_point,
new_cluster_id.to_vec().into(),
&new_cluster_id,
1,
);
let new_agent_cell =
build_normal_output_cell_with_type(&mut context, new_agent_type.clone());
Expand Down Expand Up @@ -308,7 +306,7 @@ fn test_cluster_agent_burn() {
let cluster_id = build_type_id(&input_cell, 0);
let agent_data = blake2b_256("12345676890");
let agent_type =
build_spore_type_script(&mut context, &agent_out_point, cluster_id.to_vec().into());
build_spore_type_script_with_payment(&mut context, &agent_out_point, &cluster_id, 1);
let agent_cell = build_agent_proxy_input(&mut context, &agent_data, agent_type.clone());

// build agent burn tx
Expand Down Expand Up @@ -348,7 +346,7 @@ fn test_cluster_proxy_mint() {
build_spore_contract_materials(&mut context, "cluster_proxy");
let proxy_id = build_type_id(&input_cell, 0);
let proxy_type =
build_spore_type_script(&mut context, &proxy_out_point, proxy_id.to_vec().into());
build_spore_type_script_with_payment(&mut context, &proxy_out_point, &proxy_id, 1);
let proxy_out_cell = build_normal_output_cell_with_type(&mut context, proxy_type.clone());

let tx = TransactionBuilder::default()
Expand Down Expand Up @@ -381,13 +379,13 @@ mod cluster_proxy_transfer {
let old_cluster_id = blake2b_256("12345678");
let old_proxy_id = build_type_id(&input_cell, 0);
let old_proxy_type =
build_spore_type_script(&mut context, &proxy_out_point, old_proxy_id.to_vec().into());
build_spore_type_script_with_payment(&mut context, &proxy_out_point, &old_proxy_id, 1);
let old_proxy_cell = build_agent_proxy_input(&mut context, &old_cluster_id, old_proxy_type);

// proxy in Output
let new_proxy_id = build_type_id(&input_cell, new_proxy_out_index);
let new_proxy_type =
build_spore_type_script(&mut context, &proxy_out_point, new_proxy_id.to_vec().into());
build_spore_type_script_with_payment(&mut context, &proxy_out_point, &new_proxy_id, 1);
let new_proxy_cell =
build_normal_output_cell_with_type(&mut context, new_proxy_type.clone());

Expand Down Expand Up @@ -441,7 +439,7 @@ fn test_cluster_proxy_burn() {
let cluster_id = blake2b_256("12345678");
let proxy_id = build_type_id(&input_cell, 0);
let proxy_type =
build_spore_type_script(&mut context, &proxy_out_point, proxy_id.to_vec().into());
build_spore_type_script_with_payment(&mut context, &proxy_out_point, &proxy_id, 1);
let proxy_cell = build_agent_proxy_input(&mut context, &cluster_id, proxy_type.clone());

// build proxy burn tx
Expand Down
2 changes: 1 addition & 1 deletion tests/src/tests/spore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ mod simple_spore_destroy {
let tx = TransactionBuilder::default()
.input(spore_input)
.output(normal_output)
.output_data(serialized.as_slice().pack())
.output_data(Default::default())
.cell_dep(spore_script_dep)
.build();

Expand Down
10 changes: 10 additions & 0 deletions tests/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ pub fn build_spore_type_script(
context.build_script_with_hash_type(out_point, ScriptHashType::Data1, args)
}

pub fn build_spore_type_script_with_payment(
context: &mut Context,
out_point: &OutPoint,
args: &[u8; 32],
payment: u8,
) -> Option<Script> {
let args = vec![args.to_vec(), vec![payment]].concat();
context.build_script_with_hash_type(out_point, ScriptHashType::Data1, args.into())
}

pub fn build_spore_input(
context: &mut Context,
spore_type: Option<Script>,
Expand Down

0 comments on commit 604d430

Please sign in to comment.