@@ -2143,6 +2143,50 @@ private void checkForkRecovery(boolean failRestore, boolean retryOldHead,
21432143 }
21442144 }
21452145
2146+ @ Test
2147+ public void authsRejectedFromPendingButAcceptedInBlock () throws Exception {
2148+ String key = PublicMethod .getRandomPrivateKey ();
2149+ byte [] privateKey = ByteArray .fromHexString (key );
2150+ ByteString address = ByteString .copyFrom (ECKey .fromPrivate (privateKey ).getAddress ());
2151+ chainManager .getAccountStore ().put (address .toByteArray (),
2152+ new AccountCapsule (Account .newBuilder ().setAddress (address ).build ()));
2153+ chainManager .getWitnessScheduleStore ().saveActiveWitnesses (new ArrayList <>());
2154+ chainManager .addWitness (address );
2155+ chainManager .getWitnessStore ().put (address .toByteArray (), new WitnessCapsule (address ));
2156+ long time = 1533529947843L ;
2157+ dbManager .pushBlock (new BlockCapsule (
2158+ blockGenerate .getSignedBlock (address , time , privateKey )));
2159+ Map <ByteString , String > keys = addTestWitnessAndAccount ();
2160+ keys .put (address , key );
2161+
2162+ ECKey ownerKey = new ECKey (Utils .getRandom ());
2163+ byte [] owner = ownerKey .getAddress ();
2164+ chainManager .getAccountStore ().put (owner , new AccountCapsule (Account .newBuilder ()
2165+ .setAddress (ByteString .copyFrom (owner )).setBalance (1_000_000_000L ).build ()));
2166+ BlockCapsule parent = createTestBlockCapsule (time + 3000 , chainManager .getHeadBlockNum () + 1 ,
2167+ chainManager .getHeadBlockId ().getByteString (), keys );
2168+ dbManager .pushBlock (parent );
2169+
2170+ Transaction base = transfer (owner , address .toByteArray (), 1L , parent , time + 1_000_000L )
2171+ .getInstance ();
2172+ Transaction withAuths = base .toBuilder ().setRawData (base .getRawData ().toBuilder ()
2173+ .addAuths (Protocol .authority .getDefaultInstance ())).build ();
2174+ ContractValidateException pending = assertThrows (ContractValidateException .class ,
2175+ () -> dbManager .pushTransaction (new TransactionCapsule (withAuths )));
2176+ Assert .assertEquals (ContractValidateException .class , pending .getClass ());
2177+ Assert .assertEquals ("Transaction auths are not supported." , pending .getMessage ());
2178+
2179+ TransactionCapsule signed = new TransactionCapsule (withAuths );
2180+ signed .sign (ownerKey .getPrivKeyBytes ());
2181+ BlockCapsule block = new BlockCapsule (blockWithTransfer (time + 6000 , parent .getNum () + 1 ,
2182+ parent .getBlockId ().getByteString (), keys , signed ).getData ());
2183+ dbManager .pushBlock (block );
2184+
2185+ Assert .assertEquals (block .getBlockId (), chainManager .getHeadBlockId ());
2186+ Assert .assertTrue (chainManager .getTransactionStore ()
2187+ .has (signed .getTransactionId ().getBytes ()));
2188+ }
2189+
21462190 private TransactionCapsule transfer (byte [] owner , byte [] to , long amount ,
21472191 BlockCapsule refBlock , long expiration ) {
21482192 TransferContract contract = TransferContract .newBuilder ()
0 commit comments