Skip to content

Commit

Permalink
Merge remote-tracking branch 'simelo/stdevHan_t105_update_submodule_0…
Browse files Browse the repository at this point in the history
….27.0' into stdevAlDen_t108_refactor_libskycoin_assert

Conflicts:
	lib/cgo/tests/testutils/libsky_assert.common.c
ref #108
  • Loading branch information
Alvaro Denis committed Sep 16, 2019
2 parents c9e12bb + b08948a commit ca974af
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added function `SKY_cli_GetWalletOutputs`
- Added function `SKY_cli_GetBalanceOfAddresses`
- Added datatype `GetOutputser__Handle`
- Added functions `SKY_coin_DeserializeTransactionHex`

### Removed

Expand Down
4 changes: 2 additions & 2 deletions lib/cgo/cipher.bip32.path.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func SKY_bip32_Path_GetElements(handle C.Path__Handle, post int, _arg0 *C.bip32_
____error_code = SKY_BAD_HANDLE
return
}

*_arg0 = *(*C.bip32__PathNode)(unsafe.Pointer(&p.Elements[post]))
return
}
}
4 changes: 2 additions & 2 deletions lib/cgo/cipher.bip44.bip44.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ func SKY_bip44_Account_GetPrivateKey(_a C.Account__Handle, _arg0 *C.PrivateKey__
return
}

* _arg0 = registerPrivateKeyHandle(a.PrivateKey)
*_arg0 = registerPrivateKeyHandle(a.PrivateKey)
return
}
}
12 changes: 12 additions & 0 deletions lib/cgo/coin.transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,3 +734,15 @@ func SKY_coin_Transaction_SetInnerHash(handle *C.Transaction__Handle, _sha *C.ci
tx.InnerHash = uxHash
return
}

//export SKY_coin_DeserializeTransactionHex
func SKY_coin_DeserializeTransactionHex(_s string, _arg0 *C.Transaction__Handle) (___error_code uint32) {

arg0, err := coin.DeserializeTransactionHex(_s)

___error_code = libErrorCode(err)
if err == nil {
*_arg0 = registerTransactionHandle(&arg0)
}
return
}
15 changes: 13 additions & 2 deletions lib/cgo/libsky_handle_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ func SKY_Handle_Strings_Sort(handle C.Strings__Handle) uint32 {
}

//export SKY_Handle_Strings_GetAt
func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, index int, str *C.GoString_) uint32 {
func SKY_Handle_Strings_GetAt(handle C.Strings__Handle, index int, str *string) uint32 {
obj, ok := lookupStringsHandle(handle)
if ok {

copyString(obj[index], str)
*str = obj[index]
return SKY_OK

}
Expand All @@ -165,6 +165,17 @@ func SKY_Handle_Strings_SetAt(handle C.Strings__Handle, index int, str *string)
return SKY_OK
}

//nolint megacheck
//export SKY_Handle_Strings_Get
func SKY_Handle_Strings_Get(handle C.Strings__Handle, arg0 *[]string) uint32 {
obj, ok := lookupStringsHandle(handle)
if !ok {
return SKY_BAD_HANDLE
}
arg0 = &obj
return SKY_OK
}

//export SKY_api_Handle_Client_GetWalletDir
func SKY_api_Handle_Client_GetWalletDir(handle C.Client__Handle, walletDir *C.GoString_) uint32 {
client, ok := lookupClientHandle(handle)
Expand Down
2 changes: 1 addition & 1 deletion lib/cgo/libsky_mem.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ func copyTocoin_UxArray(src reflect.Value, dest *C.coin__UxArray) {
dest.len = C.GoInt_(srcLen)
}
}
}
}
11 changes: 3 additions & 8 deletions lib/cgo/params.distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ func SKY_params_Distribution_GetAddresses(_d C.Distribution__Handle, _arg0 *C.St
____error_code = SKY_BAD_HANDLE
return
}
*_arg0 = registerStringsHandle(d.Addresses)
arg0 := d.Addresses
*_arg0 = registerStringsHandle(arg0)
return
}

Expand Down Expand Up @@ -229,13 +230,7 @@ func SKY_params_Distribution_LockedAddressesDecoded(_d C.Distribution__Handle, _

//export SKY_params_Distribution_GetMainNetDistribution
func SKY_params_Distribution_GetMainNetDistribution(_d *C.Distribution__Handle) (____error_code uint32) {
d, ok := lookupDistributionHandle(*_d)
if !ok {
____error_code = SKY_BAD_HANDLE
return
}
*d = params.MainNetDistribution
*_d = registerDistributionHandle(d)
*_d = registerDistributionHandle(&params.MainNetDistribution)
return
}

Expand Down
10 changes: 4 additions & 6 deletions lib/cgo/tests/check_cipher.bitcoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@ START_TEST(TestBitcoinAddress)
error = SKY_cipher_PubKeyFromHex(*pubKeyStr, &pubkey);
ck_assert_msg(error == SKY_OK, "Create PubKey from Hex");

GoString_ str = {NULL, 0};
GoString str = {NULL, 0};
SKY_cipher_BitcoinAddressFromPubKey(&pubkey, &btcAddr);
SKY_cipher_BitcoinAddress_String(&btcAddr, &str);
registerMemCleanup((void*)str.p);
GoString tmpStr = {str.p, str.n};
ck_assert_str_eq(str.p, addrStr->p);
ck_assert(isGoStringEq(*addrStr, str));

error = SKY_cipher_BitcoinAddressFromSecKey(&seckey, &btcAddr);
ck_assert(error == SKY_OK);
GoString_ tmpstr = {buff, 0};
SKY_cipher_BitcoinAddress_String(&btcAddr, &tmpstr);
ck_assert_str_eq(tmpStr.p, addrStr->p);
SKY_cipher_BitcoinAddress_String(&btcAddr, &str);
ck_assert(isGoStringEq(*addrStr, str));
}
}
END_TEST
Expand Down
6 changes: 2 additions & 4 deletions lib/cgo/tests/check_coin.transactions.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,12 +618,10 @@ START_TEST(TestTransactionSerialization)
Transaction__Handle handle = 0;
makeTransaction(&handle);
unsigned char buffer[1024];
GoSlice_ data = {buffer, 0, 1024};
result = SKY_coin_Transaction_Serialize(handle, &data);
GoSlice d = {buffer, 0, 1024};
result = SKY_coin_Transaction_Serialize(handle, &d);
ck_assert(result == SKY_OK);
registerMemCleanup(data.data);
Transaction__Handle handle2 = 0;
GoSlice d = {data.data, data.len, data.cap};
result = SKY_coin_TransactionDeserialize(d, &handle2);
ck_assert(result == SKY_OK);
ck_assert(isTransactionHandleEq(&handle, &handle2));
Expand Down
2 changes: 1 addition & 1 deletion lib/cgo/tests/cipher.testsuite.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ void ValidateSeedData(SeedTestData* seedData, InputTestData* inputData)
keys.len = keys.cap = 0;
keys.data = NULL;

SKY_cipher_GenerateDeterministicKeyPairs(seedData->Seed, seedData->Keys.len, (GoSlice_*)&keys);
SKY_cipher_GenerateDeterministicKeyPairs(seedData->Seed, seedData->Keys.len, &keys);

ck_assert_msg(keys.data != NULL,
"SKY_cipher_GenerateDeterministicKeyPairs must allocate memory slice with zero cap");
Expand Down
4 changes: 2 additions & 2 deletions lib/swig/dynamic/mem.i
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
GoStringMap, PasswordReader__Handle_,
Transaction__Handle, Transactions__Handle, CreatedTransaction__Handle,
CreatedTransactionOutput__Handle, CreatedTransactionInput__Handle, CreateTransactionResponse__Handle,
Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle,AddressUxOuts_Handle
Block__Handle, SignedBlock__Handle, BlockBody__Handle, BuildInfo_Handle, Number_Handle, Signature_Handle,AddressUxOuts_Handle,Distribution__Handle
}

%apply Handle* { Wallet__Handle*, Options__Handle*, ReadableEntry__Handle*, ReadableWallet__Handle*, WebRpcClient__Handle*,
WalletResponse__Handle*, Client__Handle*, Strings__Handle*, Wallets__Handle*, Config__Handle*,
CLI__Handle*, Context__Handle*, GoStringMap_*, PasswordReader__Handle*,
Transaction__Handle*, Transactions__Handle*, CreatedTransaction__Handle*,
CreatedTransactionOutput__Handle*, CreatedTransactionInput__Handle*, CreateTransactionResponse__Handle*,
Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*,AddressUxOuts_Handle*
Block__Handle*, SignedBlock__Handle*, BlockBody__Handle*, BuildInfo_Handle*, Number_Handle*, Signature_Handle*,AddressUxOuts_Handle*,Distribution__Handle*
}

0 comments on commit ca974af

Please sign in to comment.