-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: handle deployment plans in simnet (#1360)
* feat: handle deployment plans in simnet * chore: update clarity * refactor: improve simnet deployment plan handling and vfs * test: custom deployment plan in simnet * feat: keep customs txs when generating a new deployment plan in simnet * tests: deployment plan behaviour in simnet * chore: bump sdk version * refactor: revert vfs changes * chore: bump sdk version
- Loading branch information
1 parent
80be703
commit a340d48
Showing
27 changed files
with
902 additions
and
564 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
components/clarinet-deployments/src/deployment_plan_test.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
use std::collections::BTreeMap; | ||
|
||
use clarinet_files::{chainhook_types::StacksNetwork, FileLocation}; | ||
use clarity_repl::clarity::{ | ||
vm::types::{QualifiedContractIdentifier, StandardPrincipalData}, | ||
ClarityName, ClarityVersion, ContractName, | ||
}; | ||
|
||
use crate::types::*; | ||
|
||
fn get_test_txs() -> (TransactionSpecification, TransactionSpecification) { | ||
let contract_id = | ||
QualifiedContractIdentifier::parse("ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test") | ||
.unwrap(); | ||
let tx_sender = StandardPrincipalData::from(contract_id.issuer.clone()); | ||
|
||
let contract_publish_tx = | ||
TransactionSpecification::EmulatedContractPublish(EmulatedContractPublishSpecification { | ||
contract_name: ContractName::try_from("test".to_string()).unwrap(), | ||
emulated_sender: tx_sender.clone(), | ||
location: FileLocation::from_path_string("/contracts/test.clar").unwrap(), | ||
source: "(ok true)".to_string(), | ||
clarity_version: ClarityVersion::Clarity2, | ||
}); | ||
|
||
let contract_call_txs = | ||
TransactionSpecification::EmulatedContractCall(EmulatedContractCallSpecification { | ||
contract_id: QualifiedContractIdentifier::parse( | ||
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.test", | ||
) | ||
.unwrap(), | ||
emulated_sender: tx_sender.clone(), | ||
method: ClarityName::try_from("test".to_string()).unwrap(), | ||
parameters: vec![], | ||
}); | ||
|
||
(contract_publish_tx, contract_call_txs) | ||
} | ||
|
||
fn build_test_deployement_plan( | ||
batches: Vec<TransactionsBatchSpecification>, | ||
) -> DeploymentSpecification { | ||
DeploymentSpecification { | ||
id: 1, | ||
name: "test".to_string(), | ||
network: StacksNetwork::Simnet, | ||
stacks_node: None, | ||
bitcoin_node: None, | ||
genesis: None, | ||
contracts: BTreeMap::new(), | ||
plan: TransactionPlanSpecification { batches }, | ||
} | ||
} | ||
|
||
#[test] | ||
fn test_extract_no_contract_publish_txs() { | ||
let (contract_publish_tx, contract_call_txs) = get_test_txs(); | ||
|
||
let plan = build_test_deployement_plan(vec![ | ||
TransactionsBatchSpecification { | ||
id: 0, | ||
transactions: vec![contract_publish_tx.clone()], | ||
epoch: Some(EpochSpec::Epoch2_4), | ||
}, | ||
TransactionsBatchSpecification { | ||
id: 1, | ||
transactions: vec![contract_call_txs.clone()], | ||
epoch: Some(EpochSpec::Epoch2_4), | ||
}, | ||
]); | ||
|
||
let (new_plan, custom_txs) = plan.extract_no_contract_publish_txs(); | ||
|
||
assert_eq!( | ||
new_plan, | ||
build_test_deployement_plan(vec![TransactionsBatchSpecification { | ||
id: 0, | ||
transactions: vec![contract_publish_tx.clone()], | ||
epoch: Some(EpochSpec::Epoch2_4), | ||
},]) | ||
); | ||
|
||
assert_eq!( | ||
custom_txs, | ||
vec![TransactionsBatchSpecification { | ||
id: 1, | ||
transactions: vec![contract_call_txs.clone()], | ||
epoch: Some(EpochSpec::Epoch2_4), | ||
}] | ||
); | ||
} | ||
|
||
#[test] | ||
fn test_merge_batches() { | ||
let (contract_publish_tx, contract_call_txs) = get_test_txs(); | ||
|
||
let plan = build_test_deployement_plan(vec![ | ||
TransactionsBatchSpecification { | ||
id: 0, | ||
transactions: vec![contract_publish_tx.clone()], | ||
epoch: Some(EpochSpec::Epoch2_4), | ||
}, | ||
TransactionsBatchSpecification { | ||
id: 1, | ||
transactions: vec![contract_call_txs.clone()], | ||
epoch: Some(EpochSpec::Epoch2_4), | ||
}, | ||
]); | ||
|
||
let (mut new_plan, custom_txs) = plan.extract_no_contract_publish_txs(); | ||
|
||
assert_ne!(plan, new_plan); | ||
|
||
new_plan.merge_batches(custom_txs); | ||
|
||
assert_eq!(plan, new_plan); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.