diff --git a/Scarb.lock b/Scarb.lock index 14bb4a9d..74a4840b 100644 --- a/Scarb.lock +++ b/Scarb.lock @@ -4,3 +4,11 @@ version = 1 [[package]] name = "governance" version = "0.2.0" +dependencies = [ + "snforge_std", +] + +[[package]] +name = "snforge_std" +version = "0.1.0" +source = "git+https://github.com/foundry-rs/starknet-foundry.git?tag=v0.10.2#9c04e095cc7e23b0d6223e5ef5b51bbeec1cf6b2" diff --git a/Scarb.toml b/Scarb.toml index d5acd4bc..c48ade65 100644 --- a/Scarb.toml +++ b/Scarb.toml @@ -8,5 +8,6 @@ cairo-version = "2.1.1" [dependencies] starknet = ">=1.1.0" +snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.10.2"} [[target.starknet-contract]] diff --git a/tests/basic.cairo b/tests/basic.cairo new file mode 100644 index 00000000..31eb48bd --- /dev/null +++ b/tests/basic.cairo @@ -0,0 +1,27 @@ +use starknet::ContractAddress; + +use snforge_std::{BlockId, ContractClassTrait, start_prank}; + +use governance::contract::IGovernanceDispatcher; +use governance::contract::IGovernanceDispatcherTrait; + +//#[test] +//#[fork(url: "https://rpc.starknet-testnet.lava.build", block_id: BlockId::Number(904597))] +fn test_submit_proposal() { + let gov_contract_addr: ContractAddress = 0x7ba1d4836a1142c09dde23cb39b2885fe350912591461b5764454a255bdbac6.try_into().unwrap(); + let dispatcher = IGovernanceDispatcher { contract_address: gov_contract_addr }; + // corresponding govtoken: 0x05151bfdd47826df3669033ea7fb977d3b2d45c4f4d1c439a9edf4062bf34bfa + // has one holder, with 31 CARM: 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1 + let admin_addr: ContractAddress = 0x0583a9d956d65628f806386ab5b12dccd74236a3c6b930ded9cf3c54efc722a1.try_into().unwrap(); + //start_prank(gov_contract_addr, admin_addr); + dispatcher.submit_proposal(0x00, 1); +} + +#[test] +#[fork(url: "https://starknet-goerli.infura.io/v3/76467ebfee7944fd9e38f9dffe41df8b", block_id: BlockId::Tag(Latest))] +fn test_forking_functionality() { + let gov_contract_addr: ContractAddress = 0x7ba1d4836a1142c09dde23cb39b2885fe350912591461b5764454a255bdbac6.try_into().unwrap(); + let dispatcher = IGovernanceDispatcher { contract_address: gov_contract_addr }; + let propdetails = dispatcher.get_proposal_details(1); + assert(propdetails.payload==0x78b4ccacdc1c902281f6f13d94b6d17b1f4c44ff811c01dea504d43a264f611, 'payload not match'); +} \ No newline at end of file