|
19 | 19 | import org.junit.AfterClass;
|
20 | 20 | import org.junit.BeforeClass;
|
21 | 21 | import org.junit.Test;
|
| 22 | +import org.mockito.Mockito; |
22 | 23 | import org.slf4j.Logger;
|
23 | 24 | import org.slf4j.LoggerFactory;
|
24 | 25 | import org.tron.protos.core.TronBlock.Block;
|
@@ -104,11 +105,19 @@ public void testDBExists() {
|
104 | 105 |
|
105 | 106 | @Test
|
106 | 107 | public void testFindUTXO() {
|
| 108 | + long testAmount = 10; |
107 | 109 | Wallet wallet = new Wallet();
|
108 | 110 | wallet.init();
|
109 |
| - UTXOSet utxoSet = new UTXOSet(); |
| 111 | + SpendableOutputs spendableOutputs = new SpendableOutputs(); |
| 112 | + spendableOutputs.setAmount(testAmount + 1); |
| 113 | + spendableOutputs.setUnspentOutputs(new HashMap<>()); |
| 114 | + UTXOSet mockUtxoSet = Mockito.mock(UTXOSet.class); |
| 115 | + Mockito.when(mockUtxoSet.findSpendableOutputs(wallet.getEcKey().getPubKey(), testAmount) |
| 116 | + ).thenReturn(spendableOutputs); |
| 117 | + Mockito.when(mockUtxoSet.getBlockchain()).thenReturn(blockchain); |
| 118 | + |
110 | 119 | Transaction transaction = TransactionUtils.newTransaction(wallet,
|
111 |
| - "fd0f3c8ab4877f0fd96cd156b0ad42ea7aa82c31", 10, utxoSet); |
| 120 | + "fd0f3c8ab4877f0fd96cd156b0ad42ea7aa82c31", testAmount, mockUtxoSet); |
112 | 121 | List<Transaction> transactions = new ArrayList<>();
|
113 | 122 | transactions.add(transaction);
|
114 | 123 | blockchain.addBlock(BlockUtils.newBlock(transactions, ByteString
|
|
0 commit comments