Skip to content

Commit 7a7abb1

Browse files
committed
improving bechmark example for GH workflow
1 parent 44fffee commit 7a7abb1

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

examples/core_examples/benchmark/benchmark.c

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@ int main() {
5353
uint8_t sui_sig[97];
5454

5555
uint64_t start_time = millis();
56-
microsui_sign_ed25519(sui_sig, message, message_len, private_key_seed);
56+
int sign_result = microsui_sign_ed25519(sui_sig, message, message_len, private_key_seed);
5757
uint64_t end_time = millis();
58-
printf("\t Signature created successfully\n\n");
58+
if(sign_result == 0) {
59+
printf("\t Signature created successfully\n\n");
60+
} else {
61+
printf("\t Signature creation failed --\n");
62+
printf("\t Error code: %d -- Aborting\n\n", sign_result);
63+
return -1;
64+
}
5965

6066
// Calculate the time taken for verification
6167
uint64_t time_taken_signature = end_time - start_time;
@@ -83,7 +89,8 @@ int main() {
8389
printf("\t Signature verified successfully\n\n");
8490
} else {
8591
printf("\t Signature verification failed --\n");
86-
printf("\t Error code: %d --\n\n", verification_result);
92+
printf("\t Error code: %d -- Aborting\n\n", verification_result);
93+
return -1;
8794
}
8895

8996
// 4. Verifying the Sui Signature from the precalculated digest and signature
@@ -98,7 +105,8 @@ int main() {
98105
printf("\t Signature from digest verified successfully\n\n");
99106
} else {
100107
printf("\t Signature verification failed --\n");
101-
printf("\t Error code: %d --\n\n", verification_result_from_digest);
108+
printf("\t Error code: %d -- Aborting\n\n", verification_result_from_digest);
109+
return -1;
102110
}
103111

104112
/////// KEY MANAGEMENT ///////
@@ -112,7 +120,8 @@ int main() {
112120
printf("\t Public key derived successfully.\n\n");
113121
} else {
114122
printf("\t Public key derivation failed --\n\n");
115-
printf("\t Error code: %d --\n\n", public_key_derivation_result);
123+
printf("\t Error code: %d -- Aborting\n\n", public_key_derivation_result);
124+
return -1;
116125
}
117126

118127
printf(" 6 - Deriving a Keypair (Secret Key + Public Key) from a 32-byte Ed25519 seed private key...\n");
@@ -126,7 +135,8 @@ int main() {
126135
printf("\t Keypair derived successfully.\n\n");
127136
} else {
128137
printf("\t Keypair derivation failed --\n\n");
129-
printf("\t Error code: %d --\n\n", keypair_derivation_result);
138+
printf("\t Error code: %d -- Aborting\n\n", keypair_derivation_result);
139+
return -1;
130140
}
131141

132142
printf(" 7 - Deriving a Sui address from a 32-byte Ed25519 public key...\n");
@@ -142,7 +152,8 @@ int main() {
142152
printf("\n\n");
143153
} else {
144154
printf("\t Sui address derivation failed --\n\n");
145-
printf("\t Error code: %d --\n\n", address_derivation_result);
155+
printf("\t Error code: %d -- Aborting\n\n", address_derivation_result);
156+
return -1;
146157
}
147158

148159

@@ -159,7 +170,8 @@ int main() {
159170
printf("\t Encoding successful. Encoded Bech32 Key: %s\n\n", private_key_bech32_output);
160171
} else {
161172
printf("\t Encoding failed --\n");
162-
printf("\t Error code: %d --\n\n", encoding_result);
173+
printf("\t Error code: %d -- Aborting\n\n", encoding_result);
174+
return -1;
163175
}
164176

165177
printf(" 9 - Decoding the Sui Bech32 private key string into a 32 raw seed bytes...\n");
@@ -174,11 +186,11 @@ int main() {
174186
printf("\t Decoding successful.\n\n");
175187
} else {
176188
printf("\t Decoding failed --\n");
177-
printf("\t Error code: %d --\n\n", decoding_result);
189+
printf("\t Error code: %d -- Aborting\n\n", decoding_result);
190+
return -1;
178191
}
179192

180193

181-
182194
printf("\t MicroSui Benchmarks Results:\n");
183195
printf("\t Signatures:\n");
184196
printf("\t\t Time taken for signing from Sui Message: ");

0 commit comments

Comments
 (0)