diff --git a/starknet/src/execution_strategies/vanilla.cairo b/starknet/src/execution_strategies/vanilla.cairo index 8a52616c..1bb2d631 100644 --- a/starknet/src/execution_strategies/vanilla.cairo +++ b/starknet/src/execution_strategies/vanilla.cairo @@ -33,6 +33,10 @@ mod VanillaExecutionStrategy { ); self._num_executed.write(self._num_executed.read() + 1); } + + fn get_strategy_type(self: @ContractState) -> felt252 { + 'SimpleQuorumVanilla' + } } #[constructor] diff --git a/starknet/src/interfaces/i_execution_strategy.cairo b/starknet/src/interfaces/i_execution_strategy.cairo index a98ddb09..cfc6a728 100644 --- a/starknet/src/interfaces/i_execution_strategy.cairo +++ b/starknet/src/interfaces/i_execution_strategy.cairo @@ -11,4 +11,6 @@ trait IExecutionStrategy { votes_abstain: u256, payload: Array ); + + fn get_strategy_type(self: @TContractState) -> felt252; } diff --git a/starknet/src/tests.cairo b/starknet/src/tests.cairo index ae1d679f..11f06222 100644 --- a/starknet/src/tests.cairo +++ b/starknet/src/tests.cairo @@ -4,6 +4,7 @@ mod test_space; mod test_upgrade; mod test_stark_tx_auth; +mod execution_strategies; mod proposal_validation_strategies; mod voting_strategies; diff --git a/starknet/src/tests/execution_strategies.cairo b/starknet/src/tests/execution_strategies.cairo new file mode 100644 index 00000000..d753bcfe --- /dev/null +++ b/starknet/src/tests/execution_strategies.cairo @@ -0,0 +1 @@ +mod vanilla; diff --git a/starknet/src/tests/execution_strategies/vanilla.cairo b/starknet/src/tests/execution_strategies/vanilla.cairo new file mode 100644 index 00000000..795ca46a --- /dev/null +++ b/starknet/src/tests/execution_strategies/vanilla.cairo @@ -0,0 +1,17 @@ +#[cfg(test)] +mod tests { + use sx::execution_strategies::vanilla::{VanillaExecutionStrategy}; + + #[test] + #[available_gas(10000000)] + fn get_strategy_type() { + let mut state: VanillaExecutionStrategy::ContractState = + VanillaExecutionStrategy::unsafe_new_contract_state(); + + let strategy_type = VanillaExecutionStrategy::VanillaExecutionStrategy::get_strategy_type( + @state + ); + + assert(strategy_type == 'SimpleQuorumVanilla', 'invalid strategy type'); + } +} diff --git a/starknet/src/tests/mocks/executor.cairo b/starknet/src/tests/mocks/executor.cairo index 845fcd49..351d02f2 100644 --- a/starknet/src/tests/mocks/executor.cairo +++ b/starknet/src/tests/mocks/executor.cairo @@ -33,6 +33,10 @@ mod ExecutorExecutionStrategy { let tx: Transaction = Serde::::deserialize(ref sp4n).unwrap(); call_contract_syscall(tx.target, tx.selector, tx.data.span()).unwrap(); } + + fn get_strategy_type(self: @ContractState) -> felt252 { + 'Executor' + } } #[constructor] @@ -60,6 +64,10 @@ mod ExecutorWithoutTxExecutionStrategy { votes_abstain: u256, payload: Array ) {} + + fn get_strategy_type(self: @ContractState) -> felt252 { + 'ExecutorWithoutTx' + } } #[constructor]