From b9ab52f290ba4110321f68a566177ce1ebf99eae Mon Sep 17 00:00:00 2001 From: Maykel Arias Torres Date: Thu, 30 Jan 2020 20:53:34 -0500 Subject: [PATCH] [test-libsky] refs #116 Finalized `cipher.bip44` --- lib/cgo/tests/check_cipher.bip44.bip44.c | 41 ++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/cgo/tests/check_cipher.bip44.bip44.c b/lib/cgo/tests/check_cipher.bip44.bip44.c index 541f4a067..ea496bbb2 100644 --- a/lib/cgo/tests/check_cipher.bip44.bip44.c +++ b/lib/cgo/tests/check_cipher.bip44.bip44.c @@ -37,23 +37,24 @@ START_TEST(TestNewCoin) GoSlice tmp = {bufferTmp, 0, 1024}; randBytes(&tmp, 3); Coin__Handle coin = 0; - GoUint32 err = SKY_bip44_NewCoin(tmp, CoinTypeBitcoin, &coin); + GoUint32 err = SKY_bip44_NewCoin(tmp, &CoinTypeBitcoin, &coin); ck_assert_int_eq(err, SKY_ErrInvalidSeedLength); // bad coin_type GoUint8 bufferBad[1024]; GoSlice Bad = {bufferBad, 0, 1024}; mustDefaultSeed(&Bad); - err = SKY_bip44_NewCoin(Bad, FirstHardenedChild, &coin); + err = SKY_bip44_NewCoin(Bad, &FirstHardenedChild, &coin); ck_assert_int_eq(err, SKY_ErrInvalidCoinType); - err = SKY_bip44_NewCoin(Bad, (FirstHardenedChild + 1), &coin); + GoUint32_ FirstHardenedChild_tmp = FirstHardenedChild + 1; + err = SKY_bip44_NewCoin(Bad, &FirstHardenedChild_tmp, &coin); ck_assert_int_eq(err, SKY_ErrInvalidCoinType); Coin__Handle c = 0; - err = SKY_bip44_NewCoin(Bad, CoinTypeBitcoin, &c); + err = SKY_bip44_NewCoin(Bad, &CoinTypeBitcoin, &c); ck_assert_int_eq(err, SKY_OK); Account__Handle account = 0; - err = SKY_bip44_Coin_Account(c, 0, &account); + err = SKY_bip44_Coin_Account(&c, 0, &account); ck_assert_int_eq(err, SKY_OK); GoUint8 bufferAccStr[1024]; GoString acc_string = {bufferAccStr, 0}; @@ -68,11 +69,11 @@ START_TEST(TestNewCoin) ck_assert_int_eq(err, SKY_OK); GoUint8 bufferPubKStr[1024]; GoString pubk_string = {bufferPubKStr, 0}; - err = SKY_bip32_PublicKey_String(pubk, &pubk_string); + err = SKY_bip32_PublicKey_String(&pubk, &pubk_string); ck_assert_int_eq(err, SKY_OK); ck_assert_str_eq(pubk_string.p, "xpub6CJWevR9X57jrYr8jrAqctxF4o78p4GCYHH34rajeL8J9D1bWSHKBht4yzwiTQ4FP4HyQpx99iLxvU54rbEbcxBUgxzTGGudBVXb1N2gcHF"); - err = SKY_bip44_Coin_Account(c, 1, &account); + err = SKY_bip44_Coin_Account(&c, 1, &account); ck_assert_int_eq(err, SKY_OK); err = SKY_bip44_Account_String(account, &acc_string); ck_assert_int_eq(err, SKY_OK); @@ -83,33 +84,33 @@ START_TEST(TestNewCoin) ck_assert_int_eq(err, SKY_OK); err = SKY_bip32_PrivateKey_Publickey(privk, &pubk); ck_assert_int_eq(err, SKY_OK); - err = SKY_bip32_PublicKey_String(pubk, &pubk_string); + err = SKY_bip32_PublicKey_String(&pubk, &pubk_string); ck_assert_int_eq(err, SKY_OK); ck_assert_str_eq(pubk_string.p, "xpub6CJWevR9X57jtvmjdnVJEgMPocfrPNcWQwvPUXJ6coJnzV3mx1hRgYXPmQJh5vLQvrVCY8LtJB5xLLiPJVmpSwBe2yhonQLoQuSsCF8YPLN"); Account__Handle account_temp = 0; - err = SKY_bip44_Coin_Account(c, 0x80000000, &account_temp); + err = SKY_bip44_Coin_Account(&c, 0x80000000, &account_temp); ck_assert_int_eq(err, SKY_ErrInvalidAccount); - err = SKY_bip44_Coin_Account(c, 0x80000001, &account_temp); + err = SKY_bip44_Coin_Account(&c, 0x80000001, &account_temp); ck_assert_int_eq(err, SKY_ErrInvalidAccount); PrivateKey__Handle external = 0; - err = SKY_bip44_Account_External(account, &external); + err = SKY_bip44_Account_External(&account, &external); ck_assert_int_eq(err, SKY_OK); GoUint8 bufferPrivKStr[1024]; GoString privk_string = {bufferPrivKStr, 0}; - err = SKY_bip32_PrivateKey_String(external, &privk_string); + err = SKY_bip32_PrivateKey_String(&external, &privk_string); ck_assert_int_eq(err, SKY_OK); ck_assert_str_eq(privk_string.p, "xprv9zjsvjLiqSerDzbeRXPeXwz8tuQ7eRUABkgFAgLPHw1KzGKkgBhJhGaMYHM8j2KDXBZTCv4m19qjxrrD7gusrtdpZ7xzJywdXHaMZEjf3Uv"); pubk = 0; err = SKY_bip32_PrivateKey_Publickey(external, &pubk); ck_assert_int_eq(err, SKY_OK); - err = SKY_bip32_PublicKey_String(pubk, &pubk_string); + err = SKY_bip32_PublicKey_String(&pubk, &pubk_string); ck_assert_int_eq(err, SKY_OK); ck_assert_str_eq(pubk_string.p, "xpub6DjELEscfpD9SUg7XYveu5vsSwEc3tC1Yybqy4jzrGYJs4euDj1ZF4tqPZYvViMn9cvBobHyubuuh69PZ1szaBBx5oxPiQzD492B6C4QDHe"); PublicKey__Handle external0 = 0; - err = SKY_bip32_PrivateKey_NewPublicChildKey(external, 0, &external0); + err = SKY_bip32_PrivateKey_NewPublicChildKey(&external, 0, &external0); ck_assert_int_eq(err, SKY_OK); GoUint8 bufferKey[1024]; GoUint8 bufferKeyStr[1024]; @@ -124,7 +125,7 @@ START_TEST(TestNewCoin) ck_assert_str_eq(KeyStr.p, "034d36f3bcd74e19204e75b81b9c0726e41b799858b92bab73f4cd7498308c5c8b"); PublicKey__Handle external1 = 0; - err = SKY_bip32_PrivateKey_NewPublicChildKey(external, 1, &external1); + err = SKY_bip32_PrivateKey_NewPublicChildKey(&external, 1, &external1); ck_assert_int_eq(err, SKY_OK); GoUint8 bufferKey1[1024]; GoUint8 bufferKey1Str[1024]; @@ -139,20 +140,20 @@ START_TEST(TestNewCoin) ck_assert(strncmp(Key1Str.p, "02f7309e9f559d847ee9cc9ee144cfa490791e33e908fdbde2dade50a389408b01", 66) == 0); PrivateKey__Handle change = 0; - err = SKY_bip44_Account_Change(account, &change); + err = SKY_bip44_Account_Change(&account, &change); ck_assert_int_eq(err, SKY_OK); - err = SKY_bip32_PrivateKey_String(change, &privk_string); + err = SKY_bip32_PrivateKey_String(&change, &privk_string); ck_assert_int_eq(err, SKY_OK); ck_assert(strncmp(privk_string.p, "xprv9zjsvjLiqSerGzJyBrpZgCaGpQCeFDnZEuAV714WigmFyHT4nFLhZLeuHzLNE19PgkZeQ5Uf2pjFZjQTHbkugDbmw5TAPAvgo2jsaTnZo2A", 66) == 0); pubk = 0; err = SKY_bip32_PrivateKey_Publickey(change, &pubk); ck_assert_int_eq(err, SKY_OK); - err = SKY_bip32_PublicKey_String(pubk, &pubk_string); + err = SKY_bip32_PublicKey_String(&pubk, &pubk_string); ck_assert_int_eq(err, SKY_OK); ck_assert(strncmp(pubk_string.p, "xpub6DjELEscfpD9VUPSHtMa3LX1NS38egWQc865uPU8H2JEr5nDKnex78yP9GxhFr5cnCRgiQF1dkv7aR7moraPrv73KHwSkDaXdWookR1Sh9p", 66) == 0); PublicKey__Handle change0 = 0; - err = SKY_bip32_PrivateKey_NewPublicChildKey(change, 0, &change0); + err = SKY_bip32_PrivateKey_NewPublicChildKey(&change, 0, &change0); ck_assert_int_eq(err, SKY_OK); err = SKY_bip32_PublicKey_GetKey(change0, &Key); ck_assert_int_eq(err, SKY_OK); @@ -161,7 +162,7 @@ START_TEST(TestNewCoin) ck_assert(strncmp(KeyStr.p, "026d3eb891e81ecabedfa8560166af383457aedaf172af9d57d00508faa5f57c4c", 66) == 0); PublicKey__Handle change1 = 0; - err = SKY_bip32_PrivateKey_NewPublicChildKey(change, 1, &change1); + err = SKY_bip32_PrivateKey_NewPublicChildKey(&change, 1, &change1); ck_assert_int_eq(err, SKY_OK); err = SKY_bip32_PublicKey_GetKey(change1, &Key1); ck_assert_int_eq(err, SKY_OK);