text: const TransactionPool = require('./transaction-pool');
  const Transaction = require('./transaction');
  const Wallet = require('./index');
  const Blockchain = require('../blockchain');
  
  describe('TransactionPool', () => {
    let tp, wallet, transaction, bc;
  
    beforeEach(() => {
      tp = new TransactionPool();
      wallet = new Wallet();
      bc = new Blockchain();
      transaction = wallet.createTransaction('Wall-Waria-Shiganshina-District', 30, bc, tp);
    });
  
    it ('adds a transaction to the pool', () => {
      expect(tp.transactions.find(t => t.id === transaction.id)).toEqual(transaction);
    });
  
    it('updates a transaction in the pool', () => {
      const oldTransaction = JSON.stringify(transaction);
      const newTransaction = transaction.update(wallet, 'new-free-world', 40);
      tp.updateOrAddTransaction(newTransaction);
  
      expect(JSON.stringify(tp.transactions.find(t => t.id === newTransaction.id)))
        .not.toEqual(oldTransaction);
    });
  
    it('clears transactions', () => {
      tp.clearPool();
      expect(tp.transactions).toEqual([]);
    });
  
    describe('Mixing valid and corrupt transactions', () => {
      let validTransactions;
  
      beforeEach(() => {
        validTransactions = [...tp.transactions];
        for (let i=0; i<9; i++) {
          wallet =new Wallet();
          transaction = wallet.createTransaction('random-adress-for-the-lolz', 30, bc, tp);
          if (i%2==0){
            transaction.input.amount = 5555;
          } else {
            validTransactions.push(transaction);
          }
        }
      });
  
      it('shows a difference between valid and corrupt transactions', () => {
        expect(JSON.stringify(tp.transactions)).not.toEqual(JSON.stringify(validTransactions));
      });
      it('grabs valid transactions', () => {
        expect(tp.validTransactions()).toEqual(validTransactions);
      });
    });
  });
  