Skip to content

Commit

Permalink
Fixing RPC tests
Browse files Browse the repository at this point in the history
  • Loading branch information
levonpetrosyan93 committed Dec 23, 2020
1 parent 7f61976 commit 3a79943
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
17 changes: 8 additions & 9 deletions qa/rpc-tests/lelantus_mintspend.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@ def run_test(self):
start_bal = self.nodes[0].getbalance()

mint_trans = list()
coin = 100000000;
mint_trans.append(self.nodes[0].mintlelantus(1))
mint_trans.append(self.nodes[0].mintlelantus(2))

# Get last added transaction and fee for it
info = self.nodes[0].gettransaction(mint_trans[-1])
info = self.nodes[0].gettransaction(mint_trans[-1][0])

# fee in transaction is negative
fee = -(info['fee'] * 2)
cur_bal = self.nodes[0].getbalance()
start_bal = float(start_bal) - float(fee) - coin * 3
start_bal = float(start_bal) - float(fee) - 3
start_bal = Decimal(format(start_bal, '.8f'))

assert start_bal == cur_bal, \
Expand All @@ -40,7 +39,7 @@ def run_test(self):
# confirmations should be i due to less than 4 blocks was generated after transactions send
for i in range(5):
for tr in mint_trans:
info = self.nodes[0].gettransaction(tr)
info = self.nodes[0].gettransaction(tr[0])
confrms = info['confirmations']
assert confrms == i, \
'Confirmations should be {}, ' \
Expand All @@ -51,7 +50,7 @@ def run_test(self):
assert tr_type == 'mint', 'Unexpected transaction type: {}'.format(tr_type)

res = False
args = {'THAYjKnnCsN5xspnEcb1Ztvw4mSPBuwxzU': coin}
args = {'THAYjKnnCsN5xspnEcb1Ztvw4mSPBuwxzU': 1}
try:
res = self.nodes[0].joinsplit(args)
except JSONRPCException as ex:
Expand All @@ -67,7 +66,7 @@ def run_test(self):
self.sync_all()

for tr in mint_trans:
info = self.nodes[0].gettransaction(tr)
info = self.nodes[0].gettransaction(tr[0])
confrms = info['confirmations']
assert confrms == 6, \
'Confirmations should be 6, ' \
Expand All @@ -86,8 +85,8 @@ def run_test(self):
total_spend_fee = 0

myaddr = self.nodes[0].listreceivedbyaddress(0, True)[0]['address']
print(coin)
args = {myaddr: coin}
print(1)
args = {myaddr: 1}

spend_trans.append(self.nodes[0].joinsplit(args))

Expand All @@ -97,7 +96,7 @@ def run_test(self):
total_spend_fee += -info['fee']
print(info['fee'])
print(self.nodes[0].getbalance())
spend_total = float(spend_total) + coin
spend_total = float(spend_total) + 1
assert confrms == 0, \
'Confirmations should be 0, ' \
'due to 0 blocks was generated after transaction was created,' \
Expand Down
5 changes: 2 additions & 3 deletions src/wallet/rpcwallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2032,12 +2032,11 @@ UniValue gettransaction(const JSONRPCRequest& request)
CAmount nDebit = wtx.GetDebit(filter);
CAmount nNet = nCredit - nDebit;
CAmount nFee = (wtx.IsFromMe(filter) ? wtx.tx->GetValueOut() - nDebit : 0);
if (wtx.tx->vin[0].IsLelantusJoinSplit())
nFee = (0 - lelantus::ParseLelantusJoinSplit(wtx.tx->vin[0])->getFee());

entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee)));

if (wtx.tx->vin[0].IsLelantusJoinSplit())
nFee = lelantus::ParseLelantusJoinSplit(wtx.tx->vin[0])->getFee();

if (wtx.IsFromMe(filter))
entry.push_back(Pair("fee", ValueFromAmount(nFee)));

Expand Down

0 comments on commit 3a79943

Please sign in to comment.