vector_oob.adl
1 /* 2 seed = 987654321 3 min_height = 16 4 5 [case] 6 program = "test_oob.alpha" 7 function = "oob_get" 8 input = [] 9 private_key = "APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE" 10 11 [case] 12 program = "test_oob.alpha" 13 function = "oob_set" 14 input = [] 15 private_key = "APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE" 16 17 [case] 18 program = "test_oob.alpha" 19 function = "oob_swap_remove" 20 input = [] 21 private_key = "APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE" 22 23 [case] 24 program = "test_oob.alpha" 25 function = "oob_pop" 26 input = [] 27 private_key = "APrivateKey1zkpH5Ne1Xfd79t61VhK7b6yaYz92yW5dbuVkiFheR7rwCDE" 28 */ 29 30 program test_oob.alpha { 31 storage vec: [u32]; 32 33 // OOB get: should return None 34 async transition oob_get() -> Future { 35 return async { 36 vec.clear(); 37 assert(vec.len() == 0u32); 38 39 let result = vec.get(0u32); 40 assert(result == none); 41 }; 42 } 43 44 // OOB set: should panic (transition rejected) 45 async transition oob_set() -> Future { 46 return async { 47 vec.clear(); 48 assert(vec.len() == 0u32); 49 50 vec.set(0u32, 123u32); 51 }; 52 } 53 54 // OOB swap_remove: should panic (transition rejected) 55 async transition oob_swap_remove() -> Future { 56 return async { 57 vec.clear(); 58 assert(vec.len() == 0u32); 59 60 vec.swap_remove(0u32); 61 }; 62 } 63 64 // Pop empty vector: should return None 65 async transition oob_pop() -> Future { 66 return async { 67 vec.clear(); 68 assert(vec.len() == 0u32); 69 70 let popped = vec.pop(); 71 assert(popped == none); 72 }; 73 } 74 75 @noupgrade 76 async constructor() {} 77 }