anchor.diff:          //
           Case Random(30) of
             0..20 : begin
  -            If TRandomGenerateOperation.GenerateOpTransaction(FSourceNode.Bank.SafeBox.CurrentProtocol,operationsComp,FSourceWalletKeys) then inc(FnOperationsCreated)
  -            else inc(FnOperationsCreatedFailed);
  +            inc(FnOperationsCreated,TRandomGenerateOperation.GenerateOpTransactions(FSourceNode.Bank.SafeBox.CurrentProtocol,100,operationsComp,FSourceWalletKeys));
             end;
             21..25 : begin
               If TRandomGenerateOperation.GenerateOpMultiOperation(FSourceNode.Bank.SafeBox.CurrentProtocol,operationsComp,FSourceWalletKeys) then inc(FnOperationsCreated)
  
positive.code: 
  { TRandomGenerateOperation }
  
  class function TRandomGenerateOperation.GetRandomSigner(const operationsComp: TPCOperationsComp; const aWalletKeys: TWalletKeysExt; out iKey: Integer; out nAccount: Cardinal): Boolean;
  var availAccounts : TOrderedCardinalList;
    acc : TAccount;
    i, nRounds : Integer;
  begin
    Result := False; iKey := -1; nAccount:=0; nRounds := 0;
    if (aWalletKeys.AccountsKeyList.Count<=0) then Exit;
    Repeat
      iKey := Random( aWalletKeys.AccountsKeyList.Count );
      i := aWalletKeys.AccountsKeyList.Count;
      if i<0 then Exit;
      availAccounts := aWalletKeys.AccountsKeyList.AccountKeyList[iKey];
      if availAccounts.Count<=0 then Exit; // No valid accounts
      i := availAccounts.Count;
      if (i<0) then Exit;
      // Sender:
      nAccount := availAccounts.Get( Random(availAccounts.Count) );
      acc.balance := 0;
      If Not TAccountComp.IsAccountBlockedByProtocol(nAccount,operationsComp.SafeBoxTransaction.FreezedSafeBox.BlocksCount) then begin
        if (operationsComp.OperationsHashTree.CountOperationsBySameSignerWithoutFee(nAccount)<=0) then acc := operationsComp.SafeBoxTransaction.Account(nAccount);
      end;
      inc(nRounds);
      if (nRounds>1000) then Exit;
    until (acc.balance>0);
    Result := True;
  end;
  
  class function TRandomGenerateOperation.GenerateOpTransaction(current_protocol : Word; const operationsComp: TPCOperationsComp; const aWalletKeys: TWalletKeysExt): Boolean;
  var nAccount : Cardinal;
    iKey : Integer;
    opTx : TOpTransaction;
    senderAcc,destAcc : TAccount;
    amount,fees : Int64;
    errors : AnsiString;
  begin
    Result := False;
    If Not GetRandomSigner(operationsComp,aWalletKeys,iKey,nAccount) then Exit;
    senderAcc := operationsComp.SafeBoxTransaction.Account(nAccount);
    amount := Random(Integer(senderAcc.balance));
    if amount<=0 then Exit;
    If (senderAcc.balance - amount)>0 then begin
      fees := Random( senderAcc.balance - amount )
    end else fees := 0;
  
    iKey := aWalletKeys.IndexOfAccountKey( aWalletKeys.AccountsKeyList.AccountKey[iKey] );
    if iKey<0 then Exit;
    if Not aWalletKeys.Key[iKey].HasPrivateKey then Exit;
    if Not Assigned(aWalletKeys.Key[iKey].PrivateKey) then Exit;
    // Dest
    Repeat
      destAcc := operationsComp.SafeBoxTransaction.Account( Random(operationsComp.SafeBoxTransaction.FreezedSafeBox.AccountsCount) );
    until (destAcc.account <> senderAcc.account);
  
    // Search account
    opTx := TOpTransaction.CreateTransaction(current_protocol,senderAcc.account,senderAcc.n_operation+1,destAcc.account,aWalletKeys.Key[iKey].PrivateKey,amount,fees,'');
    Try
      Result := operationsComp.AddOperation(True,opTx,errors);
    finally
      opTx.Free;
    end;
  end;
  
  
negative.code:   TRandomGenerateOperation = Class
    private
    public
      class function GetRandomOwnDestination(const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt; out nAccount : Cardinal) : Boolean;
      class function GetRandomSigner(const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt; out iKey : Integer; out nAccount : Cardinal) : Boolean;
      class function GenerateOpTransactions(current_protocol : Word; Maxtransaction : Integer; const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt) : Integer;
      class function GenerateOpMultiOperation(current_protocol : Word; const operationsComp : TPCOperationsComp; const aWalletKeys : TWalletKeysExt) : Boolean;
    end;
  
  