@@ -580,14 +580,24 @@ public void pushSwitchFork()
580580 TaposException , ReceiptCheckErrException , TooBigTransactionException ,
581581 AccountResourceInsufficientException , EventBloomException {
582582
583- String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62" ;
584- String key2 = "c85ef7d79691fe79573b1a7064c19c1a9819ebdbd1faaab1a8ec92344438aaf4" ;
583+ String key = PublicMethod . getRandomPrivateKey () ;
584+ String key2 = PublicMethod . getRandomPrivateKey () ;
585585 byte [] privateKey = ByteArray .fromHexString (key );
586586 final ECKey ecKey = ECKey .fromPrivate (privateKey );
587587 byte [] address = ecKey .getAddress ();
588+
589+ ByteString addressByte = ByteString .copyFrom (address );
590+ AccountCapsule accountCapsule =
591+ new AccountCapsule (Protocol .Account .newBuilder ()
592+ .setAddress (addressByte ).build ());
593+ chainManager .getAccountStore ()
594+ .put (addressByte .toByteArray (), accountCapsule );
595+
588596 WitnessCapsule sr1 = new WitnessCapsule (
589597 ByteString .copyFrom (address ), "www.tron.net/first" );
590598 sr1 .setVoteCount (1000000000L );
599+
600+
591601 byte [] privateKey2 = ByteArray .fromHexString (key2 );
592602 final ECKey ecKey2 = ECKey .fromPrivate (privateKey2 );
593603 byte [] address2 = ecKey2 .getAddress ();
@@ -703,13 +713,23 @@ public void fork()
703713 Args .setParam (new String []{"--witness" }, Constant .TEST_CONF );
704714 long size = chainManager .getBlockStore ().size ();
705715 // System.out.print("block store size:" + size + "\n");
706- String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62" ;
716+ String key = PublicMethod . getRandomPrivateKey () ;
707717 byte [] privateKey = ByteArray .fromHexString (key );
708718 final ECKey ecKey = ECKey .fromPrivate (privateKey );
709719 byte [] address = ecKey .getAddress ();
720+
721+ ByteString addressByte = ByteString .copyFrom (address );
722+ AccountCapsule accountCapsule =
723+ new AccountCapsule (Protocol .Account .newBuilder ()
724+ .setAddress (addressByte ).build ());
725+ chainManager .getAccountStore ()
726+ .put (addressByte .toByteArray (), accountCapsule );
727+
728+
710729 WitnessCapsule witnessCapsule = new WitnessCapsule (ByteString .copyFrom (address ));
711730 chainManager .getWitnessScheduleStore ().saveActiveWitnesses (new ArrayList <>());
712731 chainManager .addWitness (ByteString .copyFrom (address ));
732+ chainManager .getWitnessStore ().put (address , witnessCapsule );
713733
714734 Block block = getSignedBlock (witnessCapsule .getAddress (), 1533529947843L , privateKey );
715735
@@ -822,14 +842,20 @@ public void doNotSwitch()
822842 Args .setParam (new String []{"--witness" }, Constant .TEST_CONF );
823843 long size = chainManager .getBlockStore ().size ();
824844 System .out .print ("block store size:" + size + "\n " );
825- String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62" ;
845+ String key = PublicMethod . getRandomPrivateKey () ;
826846 byte [] privateKey = ByteArray .fromHexString (key );
827847 final ECKey ecKey = ECKey .fromPrivate (privateKey );
828848 byte [] address = ecKey .getAddress ();
829-
849+ ByteString addressByte = ByteString .copyFrom (address );
850+ AccountCapsule accountCapsule =
851+ new AccountCapsule (Protocol .Account .newBuilder ()
852+ .setAddress (addressByte ).build ());
853+ chainManager .getAccountStore ()
854+ .put (addressByte .toByteArray (), accountCapsule );
830855 WitnessCapsule witnessCapsule = new WitnessCapsule (ByteString .copyFrom (address ));
831856 chainManager .getWitnessScheduleStore ().saveActiveWitnesses (new ArrayList <>());
832857 chainManager .addWitness (ByteString .copyFrom (address ));
858+ chainManager .getWitnessStore ().put (address , witnessCapsule );
833859
834860 Block block = getSignedBlock (witnessCapsule .getAddress (), 1533529947843L , privateKey );
835861 dbManager .pushBlock (new BlockCapsule (block ));
@@ -928,14 +954,22 @@ public void switchBack()
928954 Args .setParam (new String []{"--witness" }, Constant .TEST_CONF );
929955 long size = chainManager .getBlockStore ().size ();
930956 System .out .print ("block store size:" + size + "\n " );
931- String key = "f31db24bfbd1a2ef19beddca0a0fa37632eded9ac666a05d3bd925f01dde1f62" ;
957+ String key = PublicMethod . getRandomPrivateKey (); ;
932958 byte [] privateKey = ByteArray .fromHexString (key );
933959 final ECKey ecKey = ECKey .fromPrivate (privateKey );
934960 byte [] address = ecKey .getAddress ();
961+
962+ ByteString addressByte = ByteString .copyFrom (address );
963+ AccountCapsule accountCapsule =
964+ new AccountCapsule (Protocol .Account .newBuilder ()
965+ .setAddress (addressByte ).build ());
966+ chainManager .getAccountStore ()
967+ .put (addressByte .toByteArray (), accountCapsule );
968+
935969 WitnessCapsule witnessCapsule = new WitnessCapsule (ByteString .copyFrom (address ));
936970 chainManager .getWitnessScheduleStore ().saveActiveWitnesses (new ArrayList <>());
937971 chainManager .addWitness (ByteString .copyFrom (address ));
938-
972+ chainManager . getWitnessStore (). put ( address , witnessCapsule );
939973 Block block = getSignedBlock (witnessCapsule .getAddress (), 1533529947843L , privateKey );
940974 dbManager .pushBlock (new BlockCapsule (block ));
941975
0 commit comments