Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix(common): Fix send_trytes parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu Wei Wu committed Mar 22, 2019
1 parent 7d431e5 commit cd5202f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
10 changes: 5 additions & 5 deletions accelerator/common_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ status_t ta_attach_to_tangle(const attach_to_tangle_req_t* const req,
return ret;
}

status_t ta_send_trytes(const iota_client_service_t* const service,
uint8_t const depth, uint8_t const mwm,
status_t ta_send_trytes(const iota_config_t* const tangle,
const iota_client_service_t* const service,
hash8019_array_p trytes) {
status_t ret = SC_OK;
ta_get_tips_res_t* get_txn_res = ta_get_tips_res_new();
Expand All @@ -175,7 +175,7 @@ status_t ta_send_trytes(const iota_client_service_t* const service,
}

// get transaction to approve
ret = cclient_get_txn_to_approve(service, depth, get_txn_res);
ret = cclient_get_txn_to_approve(service, tangle->depth, get_txn_res);
if (ret) {
goto done;
}
Expand All @@ -188,7 +188,7 @@ status_t ta_send_trytes(const iota_client_service_t* const service,
memcpy(attach_req->branch, hash243_stack_peek(get_txn_res->tips),
FLEX_TRIT_SIZE_243);
hash243_stack_pop(&get_txn_res->tips);
attach_req->mwm = mwm;
attach_req->mwm = tangle->mwm;
attach_req->trytes = trytes;
ret = ta_attach_to_tangle(attach_req, attach_res);
if (ret) {
Expand Down Expand Up @@ -275,7 +275,7 @@ status_t ta_send_transfer(const iota_config_t* const tangle,
free(serialized_txn);
}

ret = ta_send_trytes(service, tangle->depth, tangle->mwm, raw_tx);
ret = ta_send_trytes(tangle, service, raw_tx);
if (ret) {
goto done;
}
Expand Down
7 changes: 3 additions & 4 deletions accelerator/common_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,16 @@ status_t ta_send_transfer(const iota_config_t* const tangle,
* bundle and do PoW in `ta_attach_to_tangle` and store and broadcast
* transaction to tangle.
*
* @param[in] tangle IOTA API parameter configurations
* @param[in] service IRI node end point service
* @param[in] dpeth Depth of get transaction to approve
* @param[in] mwm Minimum weight magnitude
* @param[in] trytes Trytes that will be attached to tangle
*
* @return
* - SC_OK on success
* - non-zero on error
*/
status_t ta_send_trytes(const iota_client_service_t* const service,
uint8_t const depth, uint8_t const mwm,
status_t ta_send_trytes(const iota_config_t* const tangle,
const iota_client_service_t* const service,
hash8019_array_p trytes);

/**
Expand Down
7 changes: 4 additions & 3 deletions tests/iota_api_mock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ retcode_t iota_client_get_trytes(const iota_client_service_t* const service,
return APIMockObj.iota_client_get_trytes(service, req, res);
}

status_t ta_send_trytes(const iota_client_service_t* const service,
uint8_t depth, uint8_t mwm, hash8019_array_p trytes) {
return APIMockObj.ta_send_trytes(service, depth, mwm, trytes);
status_t ta_send_trytes(const iota_config_t* const tangle,
const iota_client_service_t* const service,
hash8019_array_p trytes) {
return APIMockObj.ta_send_trytes(tangle, service, trytes);
}
11 changes: 6 additions & 5 deletions tests/iota_api_mock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class IotaAPI {
get_trytes_res_t* res) {
return RC_OK;
}
virtual status_t ta_send_trytes(const iota_client_service_t* const service,
uint8_t depth, uint8_t mwm,
virtual status_t ta_send_trytes(const iota_config_t* const tangle,
const iota_client_service_t* const service,
hash8019_array_p trytes) {
return SC_OK;
}
Expand Down Expand Up @@ -80,7 +80,8 @@ class APIMock : public IotaAPI {
MOCK_METHOD3(iota_client_get_trytes,
retcode_t(const iota_client_service_t* const service,
get_trytes_req_t* const req, get_trytes_res_t* res));
MOCK_METHOD4(ta_send_trytes,
status_t(const iota_client_service_t* const service,
uint8_t depth, uint8_t mwm, hash8019_array_p trytes));
MOCK_METHOD3(ta_send_trytes,
status_t(const iota_config_t* const tangle,
const iota_client_service_t* const service,
hash8019_array_p trytes));
};
2 changes: 1 addition & 1 deletion tests/test_common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ TEST(SendTransferTest, SendTransferTest) {
flex_trits_slice(req->message, req->msg_len, msg_trits, req->msg_len, 0,
req->msg_len);

EXPECT_CALL(APIMockObj, ta_send_trytes(_, _, _, _)).Times(AtLeast(1));
EXPECT_CALL(APIMockObj, ta_send_trytes(_, _, _)).Times(AtLeast(1));
EXPECT_CALL(APIMockObj, iota_client_find_transactions(_, _, _))
.Times(AtLeast(1));

Expand Down

0 comments on commit cd5202f

Please sign in to comment.