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

Commit cd5202f

Browse files
author
Yu Wei Wu
committed
fix(common): Fix send_trytes parameters
1 parent 7d431e5 commit cd5202f

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

accelerator/common_core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ status_t ta_attach_to_tangle(const attach_to_tangle_req_t* const req,
162162
return ret;
163163
}
164164

165-
status_t ta_send_trytes(const iota_client_service_t* const service,
166-
uint8_t const depth, uint8_t const mwm,
165+
status_t ta_send_trytes(const iota_config_t* const tangle,
166+
const iota_client_service_t* const service,
167167
hash8019_array_p trytes) {
168168
status_t ret = SC_OK;
169169
ta_get_tips_res_t* get_txn_res = ta_get_tips_res_new();
@@ -175,7 +175,7 @@ status_t ta_send_trytes(const iota_client_service_t* const service,
175175
}
176176

177177
// get transaction to approve
178-
ret = cclient_get_txn_to_approve(service, depth, get_txn_res);
178+
ret = cclient_get_txn_to_approve(service, tangle->depth, get_txn_res);
179179
if (ret) {
180180
goto done;
181181
}
@@ -188,7 +188,7 @@ status_t ta_send_trytes(const iota_client_service_t* const service,
188188
memcpy(attach_req->branch, hash243_stack_peek(get_txn_res->tips),
189189
FLEX_TRIT_SIZE_243);
190190
hash243_stack_pop(&get_txn_res->tips);
191-
attach_req->mwm = mwm;
191+
attach_req->mwm = tangle->mwm;
192192
attach_req->trytes = trytes;
193193
ret = ta_attach_to_tangle(attach_req, attach_res);
194194
if (ret) {
@@ -275,7 +275,7 @@ status_t ta_send_transfer(const iota_config_t* const tangle,
275275
free(serialized_txn);
276276
}
277277

278-
ret = ta_send_trytes(service, tangle->depth, tangle->mwm, raw_tx);
278+
ret = ta_send_trytes(tangle, service, raw_tx);
279279
if (ret) {
280280
goto done;
281281
}

accelerator/common_core.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,16 @@ status_t ta_send_transfer(const iota_config_t* const tangle,
106106
* bundle and do PoW in `ta_attach_to_tangle` and store and broadcast
107107
* transaction to tangle.
108108
*
109+
* @param[in] tangle IOTA API parameter configurations
109110
* @param[in] service IRI node end point service
110-
* @param[in] dpeth Depth of get transaction to approve
111-
* @param[in] mwm Minimum weight magnitude
112111
* @param[in] trytes Trytes that will be attached to tangle
113112
*
114113
* @return
115114
* - SC_OK on success
116115
* - non-zero on error
117116
*/
118-
status_t ta_send_trytes(const iota_client_service_t* const service,
119-
uint8_t const depth, uint8_t const mwm,
117+
status_t ta_send_trytes(const iota_config_t* const tangle,
118+
const iota_client_service_t* const service,
120119
hash8019_array_p trytes);
121120

122121
/**

tests/iota_api_mock.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ retcode_t iota_client_get_trytes(const iota_client_service_t* const service,
7777
return APIMockObj.iota_client_get_trytes(service, req, res);
7878
}
7979

80-
status_t ta_send_trytes(const iota_client_service_t* const service,
81-
uint8_t depth, uint8_t mwm, hash8019_array_p trytes) {
82-
return APIMockObj.ta_send_trytes(service, depth, mwm, trytes);
80+
status_t ta_send_trytes(const iota_config_t* const tangle,
81+
const iota_client_service_t* const service,
82+
hash8019_array_p trytes) {
83+
return APIMockObj.ta_send_trytes(tangle, service, trytes);
8384
}

tests/iota_api_mock.hh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class IotaAPI {
4242
get_trytes_res_t* res) {
4343
return RC_OK;
4444
}
45-
virtual status_t ta_send_trytes(const iota_client_service_t* const service,
46-
uint8_t depth, uint8_t mwm,
45+
virtual status_t ta_send_trytes(const iota_config_t* const tangle,
46+
const iota_client_service_t* const service,
4747
hash8019_array_p trytes) {
4848
return SC_OK;
4949
}
@@ -80,7 +80,8 @@ class APIMock : public IotaAPI {
8080
MOCK_METHOD3(iota_client_get_trytes,
8181
retcode_t(const iota_client_service_t* const service,
8282
get_trytes_req_t* const req, get_trytes_res_t* res));
83-
MOCK_METHOD4(ta_send_trytes,
84-
status_t(const iota_client_service_t* const service,
85-
uint8_t depth, uint8_t mwm, hash8019_array_p trytes));
83+
MOCK_METHOD3(ta_send_trytes,
84+
status_t(const iota_config_t* const tangle,
85+
const iota_client_service_t* const service,
86+
hash8019_array_p trytes));
8687
};

tests/test_common.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ TEST(SendTransferTest, SendTransferTest) {
156156
flex_trits_slice(req->message, req->msg_len, msg_trits, req->msg_len, 0,
157157
req->msg_len);
158158

159-
EXPECT_CALL(APIMockObj, ta_send_trytes(_, _, _, _)).Times(AtLeast(1));
159+
EXPECT_CALL(APIMockObj, ta_send_trytes(_, _, _)).Times(AtLeast(1));
160160
EXPECT_CALL(APIMockObj, iota_client_find_transactions(_, _, _))
161161
.Times(AtLeast(1));
162162

0 commit comments

Comments
 (0)