Skip to content

Commit

Permalink
Fixes to hardcoded addresses and reordering of expected vouts
Browse files Browse the repository at this point in the history
  • Loading branch information
davidjaenson committed Jun 28, 2017
1 parent 5b5b3c0 commit ab94a4f
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/test/qtumtests/condensingtransaction_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,44 +114,44 @@ std::vector<valtype> code = {
valtype(ParseHex("6060604052346000575b60398060166000396000f30060606040525b600b5b5b565b0000a165627a7a7230582089f5187aa25f85528a07c69078180c9616660442c881510ebc3534a29011b49e0029")),
/*
contract Test12{
address addr = 0x747a802725849fbcf3a2ccd90e25685a4a244ab0;
address addr = 0xcf8c04c7c0a68f7483ce660df9e3056d05347d5c;
function transfer() payable {
addr.call.value(this.balance/2)(bytes4(sha3("00")));
}
function() payable { }
}
*/
valtype(ParseHex("606060405273747a802725849fbcf3a2ccd90e25685a4a244ab0600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034610000575b61017a8061006e6000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115610000570460405180807f3030000000000000000000000000000000000000000000000000000000000000815250600201905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886185025a03f19350505050505b5600a165627a7a723058209534adcc5831b13598cf32a78ded12b023f66269c90a45c87c1f36d9241594580029")),
valtype(ParseHex("606060405273cf8c04c7c0a68f7483ce660df9e3056d05347d5c600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550341561006157fe5b5b61017d806100716000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115156100ae57fe5b0460405180807f3030000000000000000000000000000000000000000000000000000000000000815250600201905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886187965a03f19350505050505b5600a165627a7a723058207f49346fdf78e94fe907fa5c0cc37c1bc5e86a5f91ef2811fe70e302cab979ee0029")),
/*
contract Test13{
address addr = 0x7e976c98b7354c2972848031d955f628a29509dc;
address addr = 0xef1bada115ec9dcc117ca8d395f649fee774498c;
function transfer() payable {
addr.call.value(this.balance/2)(bytes4(sha3("transfer()")));
}
function() payable { }
}
*/
valtype(ParseHex("6060604052737e976c98b7354c2972848031d955f628a29509dc600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034610000575b61017a8061006e6000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115610000570460405180807f7472616e73666572282900000000000000000000000000000000000000000000815250600a01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886185025a03f19350505050505b5600a165627a7a7230582046f96a0ac3f73afc70f71bcc07cdbccabe47ae51ee394a2cfab75f00d2f157eb0029")),
valtype(ParseHex("606060405273ef1bada115ec9dcc117ca8d395f649fee774498c600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550341561006157fe5b5b61017d806100716000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115156100ae57fe5b0460405180807f7472616e73666572282900000000000000000000000000000000000000000000815250600a01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886187965a03f19350505050505b5600a165627a7a72305820b568c0caeeeb3a6af971f764ca36556567fb91dd3f5beac33dbe0a18d7902dc80029")),
/*
contract Test14{
address addr = 0x2ea90ccb41921cf63b01d0f44a1a3082038d6494;
address addr = 0xbf280ab611c4866bf3d4721d834633e5e615f6c7;
function transfer() payable {
addr.call.value(this.balance/2)(bytes4(sha3("transfer()")));
}
function() payable { }
}
*/
valtype(ParseHex("6060604052732ea90ccb41921cf63b01d0f44a1a3082038d6494600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034610000575b61017a8061006e6000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115610000570460405180807f7472616e73666572282900000000000000000000000000000000000000000000815250600a01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886185025a03f19350505050505b5600a165627a7a72305820a13c5ddcd1ac647b97968133a5d983664fd76ba48cfd38ab19e259ab1288eb330029")),
valtype(ParseHex("606060405273bf280ab611c4866bf3d4721d834633e5e615f6c7600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550341561006157fe5b5b61017d806100716000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115156100ae57fe5b0460405180807f7472616e73666572282900000000000000000000000000000000000000000000815250600a01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886187965a03f19350505050505b5600a165627a7a72305820daeb96d07fc42ad749f5f2c00724a6b1818986262e8aa37572c35ef7fb1260c60029")),
/*
contract Test15{
address addr = 0x78ec6322824c9378136937e02cecde3fd36e1e18;
address addr = 0xefc304b02e965bf2fc34654a9b6c35e587aebb55;
function transfer() payable {
addr.call.value(this.balance/2)(bytes4(sha3("transfer()")));
}
function() payable { }
}
*/
valtype(ParseHex("60606040527378ec6322824c9378136937e02cecde3fd36e1e18600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555034610000575b61017a8061006e6000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115610000570460405180807f7472616e73666572282900000000000000000000000000000000000000000000815250600a01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886185025a03f19350505050505b5600a165627a7a72305820bbfbc38327968645d3f9520195b9ac616ae17bf099046cac79d605032375956f0029")),
valtype(ParseHex("606060405273efc304b02e965bf2fc34654a9b6c35e587aebb55600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550341561006157fe5b5b61017d806100716000396000f3006060604052361561003f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680638a4068dd14610048575b6100465b5b565b005b610050610052565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1660023073ffffffffffffffffffffffffffffffffffffffff16318115156100ae57fe5b0460405180807f7472616e73666572282900000000000000000000000000000000000000000000815250600a01905060405180910390207c01000000000000000000000000000000000000000000000000000000009004906040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180905060006040518083038185886187965a03f19350505050505b5600a165627a7a723058203289bd2de8b19d77e8d408d2a3f9bf60d53dda62c2aa77dec4e6d982c7aca30b0029")),
/*
contract SuicideTest{
address addr = 0x47b725b087f9ef7802b4fef599cfeb08a451e46f;
Expand Down Expand Up @@ -198,7 +198,6 @@ void checkTx(CTransaction& tx, size_t sizeVin, size_t sizeVout, std::vector<CAmo
BOOST_CHECK(tx.vout.size() == sizeVout);

for(size_t i = 0; i < tx.vout.size(); i++){
std::cout << tx.vout[i].nValue << " = " << values[i] << std::endl;
BOOST_CHECK(tx.vout[i].nValue == values[i]);
}
}
Expand Down Expand Up @@ -233,7 +232,7 @@ BOOST_AUTO_TEST_CASE(condensingtransactionbehavior_tests){
result = executeBC(txs);
balances = {5000,2500,500};
checkRes(result.second, addresses, balances, 1);
checkTx(result.second.valueTransfers[0], 1, 3, {5000,2500,500});
checkTx(result.second.valueTransfers[0], 1, 3, {2500,5000,500});

txs.clear();
txs.push_back(createQtumTransaction(code[7], 2000, dev::u256(500000), dev::u256(1), hashTemp, addresses[0]));
Expand Down Expand Up @@ -290,13 +289,12 @@ BOOST_AUTO_TEST_CASE(condensingtransactiondeep_tests){
++hashTemp;
}
auto result = executeBC(txs);

txs.clear();
txs.push_back(createQtumTransaction(code[11], 20000, dev::u256(500000), dev::u256(1), hashTemp, addresses[4]));
result = executeBC(txs);
std::vector<dev::u256> balances = {1250,1250,2500,5000,10000};
checkRes(result.second, addresses, balances, 1);
checkTx(result.second.valueTransfers[0], 1, 5, {2500,1250,5000,1250,10000});
checkTx(result.second.valueTransfers[0], 1, 5, {10000,2500,1250,1250,5000});
}

BOOST_AUTO_TEST_CASE(condensingtransactionsuicide_tests){
Expand Down Expand Up @@ -333,8 +331,8 @@ BOOST_AUTO_TEST_CASE(condensingtransactionpaytopubkeyhash_tests){
std::vector<dev::u256> balances = {6500,6500};
checkRes(result.second, addresses, balances, 1);
checkTx(result.second.valueTransfers[0], 1, 2, {6500,6500});
BOOST_CHECK(result.second.valueTransfers[0].vout[0].scriptPubKey.HasOpCall());
BOOST_CHECK(result.second.valueTransfers[0].vout[1].scriptPubKey.IsPayToPubkeyHash());
BOOST_CHECK(result.second.valueTransfers[0].vout[0].scriptPubKey.IsPayToPubkeyHash());
BOOST_CHECK(result.second.valueTransfers[0].vout[1].scriptPubKey.HasOpCall());
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit ab94a4f

Please sign in to comment.