Support conatrcts call args in rhai bindings
Some checks failed
Rhai Tests / Run Rhai Tests (push) Has been cancelled
Some checks failed
Rhai Tests / Run Rhai Tests (push) Has been cancelled
This commit is contained in:
47
src/hero_vault/ethereum/tests/contract_args_tests.rs
Normal file
47
src/hero_vault/ethereum/tests/contract_args_tests.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! Tests for smart contract argument handling functionality.
|
||||
|
||||
use ethers::types::Address;
|
||||
use std::str::FromStr;
|
||||
|
||||
use crate::hero_vault::ethereum::*;
|
||||
|
||||
#[test]
|
||||
fn test_contract_creation() {
|
||||
// Create a simple ABI
|
||||
let abi_json = r#"[
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "getValue",
|
||||
"outputs": [{"type": "uint256", "name": ""}],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [{"type": "uint256", "name": "newValue"}],
|
||||
"name": "setValue",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]"#;
|
||||
|
||||
// Parse the ABI
|
||||
let abi = load_abi_from_json(abi_json).unwrap();
|
||||
|
||||
// Create a contract address
|
||||
let address = Address::from_str("0x1234567890123456789012345678901234567890").unwrap();
|
||||
|
||||
// Create a network config
|
||||
let network = networks::gnosis();
|
||||
|
||||
// Create a contract
|
||||
let contract = Contract::new(address, abi, network);
|
||||
|
||||
// Verify the contract was created correctly
|
||||
assert_eq!(contract.address, address);
|
||||
assert_eq!(contract.network.name, "Gnosis");
|
||||
|
||||
// Verify the ABI contains the expected functions
|
||||
assert!(contract.abi.function("getValue").is_ok());
|
||||
assert!(contract.abi.function("setValue").is_ok());
|
||||
}
|
||||
Reference in New Issue
Block a user