Ejemplo n.º 1
0
TestGenerator DoubleSpendBase::prepare(std::vector<test_event_entry>& events) const {

  TestGenerator generator(m_currency, events);

  // unlock
  generator.generateBlocks();

  auto builder = generator.createTxBuilder(generator.minerAccount, m_bob_account, send_amount, m_currency.minimumFee());

  builder.setTxKeys(m_outputTxKey);
  builder.m_destinations.clear();

  TransactionBuilder::KeysVector kv;
  kv.push_back(m_bob_account.getAccountKeys());
  
  builder.addMultisignatureOut(send_amount, kv, 1);

  // move money
  auto tx = builder.build();
    
  generator.addEvent(tx);
  generator.makeNextBlock(tx);

  // unlock
  generator.generateBlocks(); 

  return generator;
}
Ejemplo n.º 2
0
//TODO: check
bool TransactionWithInputWithIndexLargerThanNumberOfOutputsWithThisSumWillBeRejected::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  KeyPair key;
  {
    auto builder = generator.createTxBuilder(generator.minerAccount, from, m_currency.depositMinAmount() + 100, m_currency.minimumFee());
    builder.m_destinations.clear();

    TransactionBuilder::KeysVector kv;
    kv.push_back(from.getAccountKeys());

    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    key = builder.getTxKeys();
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  
  generator.generateBlocks(m_currency.depositMinTerm() - 1, BLOCK_MAJOR_VERSION_2);
  
  {
    TransactionBuilder builder(m_currency);
    auto src = createSource(m_currency.depositMinTerm(), key);
    src.input.amount = m_currency.depositMinAmount() * 2;
    src.input.outputIndex = 2;
    builder.addMultisignatureInput(src);
    auto tx = builder.build();
    generator.addCallback("mark_invalid_tx");
    generator.addEvent(tx);
  }
  
  return true;
}
Ejemplo n.º 3
0
bool TransactionWithDepositUnrolesAmountAfterSwitchToAlternativeChain::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  auto lastBlock = generator.lastBlock;
  KeyPair key;
  {
    auto builder = generator.createTxBuilder(generator.minerAccount, from, m_currency.depositMinAmount() + 100, m_currency.minimumFee());
    builder.m_destinations.clear();

    TransactionBuilder::KeysVector kv;
    kv.push_back(from.getAccountKeys());

    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    key = builder.getTxKeys();
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  
  generator.addCallback("amountOneMinimal");
  generator.generateBlocks(m_currency.depositMinTerm(), BLOCK_MAJOR_VERSION_2);

  generator.addCallback("amountOneMinimal");
  generator.lastBlock = lastBlock; 
  generator.generateBlocks(m_currency.depositMinTerm() + 4, BLOCK_MAJOR_VERSION_2);
  generator.addCallback("amountZero");
  generator.generateBlocks(1, BLOCK_MAJOR_VERSION_2);
  
  return true;
}
Ejemplo n.º 4
0
bool TransactionWithAmountThatHasAlreadyFinishedWillBeAccepted::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  KeyPair key;
  {
    auto builder = generator.createTxBuilder(generator.minerAccount, from, m_currency.depositMinAmount() + 100, m_currency.minimumFee());
    builder.m_destinations.clear();

    TransactionBuilder::KeysVector kv;
    kv.push_back(from.getAccountKeys());

    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    key = builder.getTxKeys();
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  
  generator.generateBlocks(m_currency.depositMinTerm() - 1, BLOCK_MAJOR_VERSION_2);
  
  {
    TransactionBuilder builder(m_currency);
    auto src = createSource(m_currency.depositMinTerm(), key);
    builder.addMultisignatureInput(src);
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  
  return true;
}
Ejemplo n.º 5
0
bool TransactionOfTypeOneWithDepositInputIsRejected::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  KeyPair key;
  {
    auto builder = generator.createTxBuilder(generator.minerAccount, from, 100, m_currency.minimumFee() + 1);
    builder.m_destinations.clear();

    TransactionBuilder::KeysVector kv;
    kv.push_back(to.getAccountKeys());

    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm() + 1);
    key = builder.getTxKeys();
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  {
    TransactionBuilder builder(m_currency);
    builder.addMultisignatureInput(createSource(m_currency.depositMinTerm(), key));
    builder.setVersion(TRANSACTION_VERSION_1);
    auto tx = builder.build();
    generator.addCallback("mark_invalid_tx"); // should be rejected by the core
    generator.addEvent(tx);
  }
  return true;
}
Ejemplo n.º 6
0
Transaction DepositTestsBase::createDepositTransaction(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  auto builder = generator.createTxBuilder(generator.minerAccount, from, 100, m_currency.minimumFee() + 1);
  //builder.
  builder.m_destinations.clear();

  TransactionBuilder::KeysVector kv;
  kv.push_back(to.getAccountKeys());
  
  builder.addMultisignatureOut(1000, kv, 1);
  auto tx = builder.build();
  generator.addEvent(tx);
  return tx;
}
Ejemplo n.º 7
0
bool TransactionWithZeroRequiredSignaturesIsRejected::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  auto builder = generator.createTxBuilder(generator.minerAccount, from, 100, m_currency.minimumFee() + 1);
  builder.m_destinations.clear();

  TransactionBuilder::KeysVector kv;
  kv.push_back(to.getAccountKeys());

  builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 0, m_currency.depositMaxTerm());
  auto tx = builder.build();
  generator.addEvent(tx);
  return true;
}
Ejemplo n.º 8
0
bool TransactionWithTermLowerThenMinIsRejected::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  auto builder = generator.createTxBuilder(generator.minerAccount, from, 100, m_currency.minimumFee() + 1);
  builder.m_destinations.clear();

  TransactionBuilder::KeysVector kv;
  kv.push_back(to.getAccountKeys());

  builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm() - 1);
  auto tx = builder.build();
  generator.addCallback("mark_invalid_tx"); // should be rejected by the core
  generator.addEvent(tx);
  return true;
}
Ejemplo n.º 9
0
bool TransactionWithDepositRestorsEmissionOnAlternativeChain::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  KeyPair key;
  {
    auto builder = generator.createTxBuilder(generator.minerAccount, from, m_currency.depositMinAmount() + 100, m_currency.minimumFee());
    builder.m_destinations.clear();

    TransactionBuilder::KeysVector kv;
    kv.push_back(from.getAccountKeys());

    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    key = builder.getTxKeys();
    auto tx = builder.build();
    assert(tx.outputs.size() == 1);
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  
  generator.generateBlocks(m_currency.depositMinTerm() - 1, BLOCK_MAJOR_VERSION_2);
  auto lastBlock = generator.lastBlock;
  
  {
    TransactionBuilder builder(m_currency);
    auto src = createSource(m_currency.depositMinTerm(), key);
    src.input.amount = m_currency.depositMinAmount();
    builder.addMultisignatureInput(src);
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
    generator.addCallback("save_emission_before");
    generator.generateBlocks(1, BLOCK_MAJOR_VERSION_2);
  }
  
  // move to alternative chain 
  generator.lastBlock = lastBlock; 
  generator.generateBlocks(4, BLOCK_MAJOR_VERSION_2);
  generator.addCallback("save_emission_after");
  generator.generateBlocks(1, BLOCK_MAJOR_VERSION_2);
  
  return true;
}
Ejemplo n.º 10
0
bool TransactionWithDepositUpdatesInterestAfterDepositUnlockMultiple::generate(std::vector<test_event_entry>& events) {
  TestGenerator generator(m_currency, events);
  generator.generator.defaultMajorVersion = BLOCK_MAJOR_VERSION_2;
  generator.generateBlocks(m_currency.minedMoneyUnlockWindow(), BLOCK_MAJOR_VERSION_2);
  KeyPair key;
  {
    auto builder = generator.createTxBuilder(generator.minerAccount, from, m_currency.depositMinAmount() + 100, m_currency.minimumFee());
    builder.m_destinations.clear();

    TransactionBuilder::KeysVector kv;
    kv.push_back(from.getAccountKeys());

    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    builder.addMultisignatureOut(m_currency.depositMinAmount(), kv, 1, m_currency.depositMinTerm());
    key = builder.getTxKeys();
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
  }
  
  generator.generateBlocks(m_currency.depositMinTerm() - 1, BLOCK_MAJOR_VERSION_2);

  generator.addCallback("interestZero");
  {
    TransactionBuilder builder(m_currency);
    auto src1 = createSource(m_currency.depositMinTerm(), key);
    auto src2 = createSource(m_currency.depositMinTerm(), key);
    src1.input.term = m_currency.depositMinTerm();
    src2.input.term = m_currency.depositMinTerm();
    src2.input.outputIndex = 1;
    src2.srcOutputIndex = 1;
    builder.addMultisignatureInput(src1);
    builder.addMultisignatureInput(src2);
    auto tx = builder.build();
    generator.addEvent(tx);
    generator.makeNextBlock(tx);
    generator.addCallback("interestTwoMininmal");
    generator.generateBlocks(1, BLOCK_MAJOR_VERSION_2);
  }
  
  return true;
}