|
21 | 21 | import static org.junit.Assert.assertArrayEquals;
|
22 | 22 | import static org.junit.Assert.assertEquals;
|
23 | 23 | import static org.junit.Assert.assertFalse;
|
| 24 | +import static stest.tron.wallet.common.client.utils.PublicMethed.decode58Check; |
24 | 25 |
|
25 | 26 | import com.google.protobuf.Any;
|
26 | 27 | import com.google.protobuf.ByteString;
|
27 | 28 | import java.io.File;
|
| 29 | +import java.util.ArrayList; |
28 | 30 | import java.util.Arrays;
|
| 31 | +import java.util.List; |
| 32 | + |
29 | 33 | import lombok.extern.slf4j.Slf4j;
|
30 | 34 | import org.joda.time.DateTime;
|
31 | 35 | import org.junit.AfterClass;
|
|
49 | 53 | import org.tron.core.capsule.ProposalCapsule;
|
50 | 54 | import org.tron.core.capsule.TransactionCapsule;
|
51 | 55 | import org.tron.core.capsule.TransactionInfoCapsule;
|
| 56 | +import org.tron.core.capsule.WitnessCapsule; |
52 | 57 | import org.tron.core.config.DefaultConfig;
|
53 | 58 | import org.tron.core.config.args.Args;
|
54 | 59 | import org.tron.core.store.DynamicPropertiesStore;
|
@@ -559,6 +564,9 @@ public void getAnnualizedRateOfReturn() throws Exception {
|
559 | 564 | double v = wallet.getAnnualizedRateOfReturn(1,1,
|
560 | 565 | 1,1,1,1,1);
|
561 | 566 | Assert.assertEquals(730,v,0);
|
| 567 | + double v1 = wallet.getAnnualizedRateOfReturn(1,1, |
| 568 | + 1,0,1,1,1); |
| 569 | + Assert.assertEquals(0,v1,0); |
562 | 570 | }
|
563 | 571 |
|
564 | 572 | @Test
|
@@ -620,5 +628,25 @@ public void testPercentageOfBlockReward() {
|
620 | 628 | Assert.assertEquals(wallet.percentageOfBlockReward(beginCycle, endCycle, OWNER_ADDRESS
|
621 | 629 | .getBytes()), result, 10);
|
622 | 630 | }
|
| 631 | + |
| 632 | + @Test |
| 633 | + public void checkAddress() { |
| 634 | + List<ByteString> witnessAddresses = new ArrayList<>(); |
| 635 | + byte[] address = decode58Check("TT1smsmhxype64boboU8xTuNZVCKP1w6qT"); |
| 636 | + witnessAddresses.add(ByteString.copyFrom(address)); |
| 637 | + chainBaseManager.getWitnessScheduleStore().saveActiveWitnesses(witnessAddresses); |
| 638 | + Assert.assertTrue(wallet.checkAddress(address)); |
| 639 | + } |
| 640 | + |
| 641 | + @Test |
| 642 | + public void existAddress() { |
| 643 | + byte[] address = decode58Check("TT1smsmhxype64boboU8xTuNZVCKP1w6qT"); |
| 644 | + byte[] address1 = decode58Check("TB4B1RMhoPeivkj4Hebm6tttHjRY9yQFes"); |
| 645 | + WitnessCapsule witnessCapsule = new WitnessCapsule(ByteString.copyFrom(address)); |
| 646 | + chainBaseManager.getWitnessStore().put(address, witnessCapsule); |
| 647 | + Assert.assertTrue(wallet.existAddress(address)); |
| 648 | + Assert.assertFalse(wallet.existAddress(address1)); |
| 649 | + } |
| 650 | + |
623 | 651 | }
|
624 | 652 |
|
0 commit comments