state_foreign

This commit is contained in:
Richard Holland
2022-12-27 14:33:19 +00:00
parent b5cdeb5812
commit 2c77a4d3dc

View File

@@ -5388,6 +5388,7 @@ public:
#define TOO_SMALL (-4)
#define OUT_OF_BOUNDS (-1)
#define DOESNT_EXIST (-5)
#define INVALID_ARGUMENT (-7)
#define SBUF(x) (uint32_t)(x), sizeof(x)
#define sfAccount ((8U << 16U) + 1U)
int64_t hook(uint32_t reserved )
@@ -5396,14 +5397,16 @@ public:
// Test out of bounds check
ASSERT(state_foreign(1000000, 32, 0, 32, 0, 32, 0, 20) == OUT_OF_BOUNDS);
ASSERT(state_foreign(0, 1000000, 0, 32, 0, 32, 0, 20) == OUT_OF_BOUNDS);
ASSERT(state_foreign(0, 32, 1000000, 32, 0, 32, 0, 20) == OUT_OF_BOUNDS);
ASSERT(state_foreign(0, 32, 0, 1000000, 0, 32, 0, 20) == TOO_BIG);
ASSERT(state_foreign(0, 32, 0, 32, 1000000, 32, 0, 20) == OUT_OF_BOUNDS);
ASSERT(state_foreign(0, 32, 0, 32, 0, 1000000, 0, 20) == OUT_OF_BOUNDS);
ASSERT(state_foreign(0, 32, 0, 32, 0, 32, 1000000, 20) == OUT_OF_BOUNDS);
ASSERT(state_foreign(0, 32, 0, 32, 0, 32, 0, 1000000) == OUT_OF_BOUNDS);
int64_t y;
ASSERT((y=state_foreign(1111111, 32, 1, 32, 1, 32, 1, 20)) == OUT_OF_BOUNDS);
ASSERT((y=state_foreign(1, 1111111, 1, 32, 1, 32, 1, 20)) == OUT_OF_BOUNDS);
ASSERT((y=state_foreign(1, 32, 1111111, 32, 1, 32, 1, 20)) == OUT_OF_BOUNDS);
ASSERT((y=state_foreign(1, 32, 1, 1111111, 1, 32, 1, 20)) == TOO_BIG);
ASSERT((y=state_foreign(1, 32, 1, 32, 1111111, 32, 1, 20)) == OUT_OF_BOUNDS);
ASSERT((y=state_foreign(1, 32, 1, 32, 1, 1111111, 1, 20)) == INVALID_ARGUMENT);
ASSERT((y=state_foreign(1, 32, 1, 32, 1, 32, 1111111, 20)) == OUT_OF_BOUNDS);
ASSERT((y=state_foreign(1, 32, 1, 32, 1, 32, 1, 1111111)) == INVALID_ARGUMENT);
// alice's address is the sender
uint8_t acc[20];