@@ -7,101 +7,6 @@ uint64_t MAPPING_ACCOUNT_LAMPORTS = 143821440;
7
7
uint64_t PRODUCT_ACCOUNT_LAMPORTS = 4454400 ;
8
8
uint64_t PRICE_ACCOUNT_LAMPORTS = 23942400 ;
9
9
10
- Test (oracle , add_product ) {
11
- // start with perfect inputs
12
- cmd_add_product_t idata = {
13
- .ver_ = PC_VERSION ,
14
- .cmd_ = e_cmd_add_product ,
15
- };
16
- SolPubkey p_id = {.x = { 0xff , }};
17
- SolPubkey pkey = {.x = { 1 , }};
18
- SolPubkey mkey = {.x = { 2 , }};
19
- SolPubkey skey = {.x = { 3 , }};
20
- SolPubkey skey2 = {.x = { 4 , }};
21
- uint64_t pqty = 100 ;
22
- pc_map_table_t mptr [1 ];
23
- sol_memset ( mptr , 0 , sizeof ( pc_map_table_t ) );
24
- mptr -> magic_ = PC_MAGIC ;
25
- mptr -> ver_ = PC_VERSION ;
26
- mptr -> type_ = PC_ACCTYPE_MAPPING ;
27
- char sdata [PC_PROD_ACC_SIZE ];
28
- pc_prod_t * sptr = (pc_prod_t * )sdata ;
29
- sol_memset ( sptr , 0 , PC_PROD_ACC_SIZE );
30
- SolAccountInfo acc [] = {{
31
- .key = & pkey ,
32
- .lamports = & pqty ,
33
- .data_len = 0 ,
34
- .data = NULL ,
35
- .owner = NULL ,
36
- .rent_epoch = 0 ,
37
- .is_signer = true,
38
- .is_writable = true,
39
- .executable = false
40
- },{
41
- .key = & mkey ,
42
- .lamports = & MAPPING_ACCOUNT_LAMPORTS ,
43
- .data_len = sizeof ( pc_map_table_t ),
44
- .data = (uint8_t * )mptr ,
45
- .owner = & p_id ,
46
- .rent_epoch = 0 ,
47
- .is_signer = true,
48
- .is_writable = true,
49
- .executable = false
50
- },{
51
- .key = & skey ,
52
- .lamports = & PRODUCT_ACCOUNT_LAMPORTS ,
53
- .data_len = PC_PROD_ACC_SIZE ,
54
- .data = (uint8_t * )sptr ,
55
- .owner = & p_id ,
56
- .rent_epoch = 0 ,
57
- .is_signer = true,
58
- .is_writable = true,
59
- .executable = false
60
- }};
61
- SolParameters prm = {
62
- .ka = acc ,
63
- .ka_num = 3 ,
64
- .data = (const uint8_t * )& idata ,
65
- .data_len = sizeof ( idata ),
66
- .program_id = & p_id
67
- };
68
- cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
69
- cr_assert ( sptr -> magic_ == PC_MAGIC );
70
- cr_assert ( sptr -> ver_ == PC_VERSION );
71
- cr_assert ( sptr -> type_ == PC_ACCTYPE_PRODUCT );
72
- cr_assert ( sptr -> size_ == sizeof ( pc_prod_t ) );
73
- cr_assert ( mptr -> num_ == 1 );
74
- cr_assert ( pc_pub_key_equal ( (pc_pub_key_t * )& skey , & mptr -> prod_ [0 ] ) );
75
-
76
- // 2nd product
77
- acc [2 ].key = & skey2 ;
78
- sol_memset ( sptr , 0 , PC_PROD_ACC_SIZE );
79
- cr_assert ( SUCCESS == dispatch ( & prm , acc ) );
80
- cr_assert ( mptr -> num_ == 2 );
81
- cr_assert ( pc_pub_key_equal ( & mptr -> prod_ [1 ], (pc_pub_key_t * )& skey2 ) );
82
-
83
- // invalid acc size
84
- acc [2 ].data_len = 1 ;
85
- cr_assert ( ERROR_INVALID_ARGUMENT == dispatch ( & prm , acc ) );
86
- acc [2 ].data_len = PC_PROD_ACC_SIZE ;
87
-
88
- // test fill up of mapping table
89
- sol_memset ( mptr , 0 , sizeof ( pc_map_table_t ) );
90
- mptr -> magic_ = PC_MAGIC ;
91
- mptr -> ver_ = PC_VERSION ;
92
- mptr -> type_ = PC_ACCTYPE_MAPPING ;
93
- for ( unsigned i = 0 ;; ++ i ) {
94
- sol_memset ( sptr , 0 , PC_PROD_ACC_SIZE );
95
- uint64_t rc = dispatch ( & prm , acc );
96
- if ( rc != SUCCESS ) {
97
- cr_assert ( i == ( unsigned )(PC_MAP_TABLE_SIZE ) );
98
- break ;
99
- }
100
- cr_assert ( mptr -> num_ == i + 1 );
101
- cr_assert ( rc == SUCCESS );
102
- }
103
- }
104
-
105
10
Test ( oracle , add_publisher ) {
106
11
// start with perfect inputs
107
12
cmd_add_publisher_t idata = {
0 commit comments