Skip to content

Commit

Permalink
[test-libsky] refs fibercrypto#116 Correcting declare functions and t…
Browse files Browse the repository at this point in the history
…est to changes functions generations
  • Loading branch information
Maykel Arias Torres committed Jan 29, 2020
1 parent 28e5b44 commit fea15d3
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 89 deletions.
10 changes: 6 additions & 4 deletions lib/cgo/tests/check_cipher.bitcoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ START_TEST(TestBitcoinAddressNull)
{
cipher__BitcoinAddress a;
memset(&a, 0, sizeof(cipher__BitcoinAddress));
GoUint8 err = SKY_cipher_BitcoinAddress_Null(&a);
ck_assert_int_eq(err, 1);
GoUint8 nulls;
GoUint32_ err = SKY_cipher_BitcoinAddress_Null(&a, &nulls);
ck_assert_int_eq(err, SKY_OK);
ck_assert_int_eq(nulls, 1);

cipher__PubKey p;
cipher__SecKey s;
err = SKY_cipher_GenerateKeyPair(&p, &s);
memset(&a, 0, sizeof(cipher__BitcoinAddress));
SKY_cipher_BitcoinAddressFromPubKey(&p, &a);
err = SKY_cipher_BitcoinAddress_Null(&a);
ck_assert_int_eq(err, 0);
err = SKY_cipher_BitcoinAddress_Null(&a, &nulls);
ck_assert_int_eq(nulls, 0);
}
END_TEST

Expand Down
10 changes: 5 additions & 5 deletions lib/cgo/tests/check_cipher.hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,29 +127,29 @@ START_TEST(TestMerkle)

// Single hash input returns hash
hashes.len = 1;
SKY_cipher_Merkle(&hashes, &h);
SKY_cipher_Merkle(hashes, &h);
ck_assert(isU8Eq(hashlist[0], h, 32));

// 2 hashes should be Addcipher__SHA256 of them
hashes.len = 2;
SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out);
SKY_cipher_Merkle(&hashes, &h);
SKY_cipher_Merkle(hashes, &h);
ck_assert(isU8Eq(out, h, 32));

// 3 hashes should be Add(Add())
hashes.len = 3;
SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1);
SKY_cipher_AddSHA256(&hashlist[2], &zero, &out2);
SKY_cipher_AddSHA256(&out1, &out2, &out);
SKY_cipher_Merkle(&hashes, &h);
SKY_cipher_Merkle(hashes, &h);
ck_assert(isU8Eq(out, h, 32));

// 4 hashes should be Add(Add())
hashes.len = 4;
SKY_cipher_AddSHA256(&hashlist[0], &hashlist[1], &out1);
SKY_cipher_AddSHA256(&hashlist[2], &hashlist[3], &out2);
SKY_cipher_AddSHA256(&out1, &out2, &out);
SKY_cipher_Merkle(&hashes, &h);
SKY_cipher_Merkle(hashes, &h);
ck_assert(isU8Eq(out, h, 32));

// 5 hashes
Expand All @@ -161,7 +161,7 @@ START_TEST(TestMerkle)
SKY_cipher_AddSHA256(&zero, &zero, &out2);
SKY_cipher_AddSHA256(&out1, &out2, &out4);
SKY_cipher_AddSHA256(&out3, &out4, &out);
SKY_cipher_Merkle(&hashes, &h);
SKY_cipher_Merkle(hashes, &h);
ck_assert(isU8Eq(out, h, 32));
}
END_TEST
Expand Down
5 changes: 3 additions & 2 deletions lib/cgo/tests/check_cipher.secp256k1.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ START_TEST(Test_Abnormal_Keys2)
err = SKY_secp256k1_PubkeyFromSeckey(seckey_slice, &pubkey1);
ck_assert_msg(err == SKY_OK, "Fail in iteration %d, err %x != %x", i, err, SKY_OK);
GoSlice pubkey_slice = {pubkey1.data, pubkey1.len, pubkey1.cap};
err = SKY_secp256k1_VerifyPubkey(pubkey_slice);
ck_assert_msg(err == 1, "generates key that fails validation in ite #%d", i);
GoInt verf;
err = SKY_secp256k1_VerifyPubkey(pubkey_slice, &verf);
ck_assert_msg(verf == 1, "generates key that fails validation in ite #%d", i);
}
}
END_TEST
Expand Down
10 changes: 5 additions & 5 deletions lib/cgo/tests/check_coin.outputs.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ START_TEST(TestAddressUxOutsKeys)
}

coin__UxArray uxa = {uxs, test_count, test_count};
AddressUxOuts_Handle uxOutsHandle;
AddressUxOuts__Handle uxOutsHandle;
result = SKY_coin_NewAddressUxOuts(&uxa, &uxOutsHandle);
ck_assert_msg(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed");
GoSlice_ keys = {NULL, 0, 0};
Expand Down Expand Up @@ -539,7 +539,7 @@ START_TEST(TestAddressUxOutsSub)
makeUxArray(&uxa, 4);
coin__UxOut* pData = uxa.data;
memset(&empty, 0, sizeof(coin__UxArray));
AddressUxOuts_Handle h1, h2, h3;
AddressUxOuts__Handle h1, h2, h3;
result = SKY_coin_NewAddressUxOuts(&empty, &h1);
ck_assert_msg(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed");
registerHandleClose(h1);
Expand Down Expand Up @@ -628,7 +628,7 @@ START_TEST(TestAddressUxOutsAdd)
makeUxArray(&uxa, 4);
coin__UxOut* pData = uxa.data;
memset(&empty, 0, sizeof(coin__UxArray));
AddressUxOuts_Handle h1, h2, h3;
AddressUxOuts__Handle h1, h2, h3;
result = SKY_coin_NewAddressUxOuts(&empty, &h1);
ck_assert_msg(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed");
registerHandleClose(h1);
Expand Down Expand Up @@ -735,7 +735,7 @@ START_TEST(TestAddressUxOutsFlatten)
coin__UxOut* pData = uxa.data;
memcpy(&(pData + 2)->Body.Address, &(pData + 1)->Body.Address, sizeof(cipher__Address));
memset(&emptyArray, 0, sizeof(coin__UxArray));
AddressUxOuts_Handle h;
AddressUxOuts__Handle h;
result = SKY_coin_NewAddressUxOuts(&emptyArray, &h);
ck_assert_msg(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed");
registerHandleClose(h);
Expand Down Expand Up @@ -792,7 +792,7 @@ START_TEST(TestNewAddressUxOuts)
memcpy(&(pData + 1)->Body.Address, &(pData)->Body.Address, sizeof(cipher__Address));
memcpy(&(pData + 3)->Body.Address, &(pData + 2)->Body.Address, sizeof(cipher__Address));
memcpy(&(pData + 4)->Body.Address, &(pData + 2)->Body.Address, sizeof(cipher__Address));
AddressUxOuts_Handle h;
AddressUxOuts__Handle h;
result = SKY_coin_NewAddressUxOuts(&uxa, &h);
ck_assert_msg(result == SKY_OK, "SKY_coin_NewAddressUxOuts failed");
registerHandleClose(h);
Expand Down
Loading

0 comments on commit fea15d3

Please sign in to comment.