Add subsequent_vote test

This is the contracts/extension that triggered a Rust ICE, as noted in 
my issue there.
This commit is contained in:
Luke Parker
2022-07-18 02:53:45 -04:00
parent aa0d364fc2
commit 21e555192c
2 changed files with 44 additions and 11 deletions

View File

@@ -34,6 +34,16 @@ impl Environment for SeraiEnvironment {
type ChainExtension = SeraiExtension;
}
pub fn test_validators() -> Vec<AccountId> {
vec![
AccountId::from([1; 32]),
AccountId::from([2; 32]),
AccountId::from([3; 32]),
AccountId::from([4; 32]),
AccountId::from([5; 32]),
]
}
pub fn test_register() {
struct ExtensionLen;
impl ink_env::test::ChainExtension for ExtensionLen {
@@ -42,7 +52,7 @@ pub fn test_register() {
}
fn call(&mut self, _: &[u8], output: &mut Vec<u8>) -> u32 {
scale::Encode::encode_to(&5u16, output);
scale::Encode::encode_to(&u16::try_from(test_validators().len()).unwrap(), output);
0
}
}
@@ -72,13 +82,7 @@ pub fn test_register() {
let potential = AccountId::decode(&mut &input[1 ..]).unwrap(); // TODO: Why is this 1 ..?
let mut presence = false;
for validator in [
AccountId::from([1; 32]),
AccountId::from([2; 32]),
AccountId::from([3; 32]),
AccountId::from([4; 32]),
AccountId::from([5; 32])
].clone() {
for validator in test_validators() {
if potential == validator {
presence = true;
}