| 552 | } |
| 553 | |
| 554 | int ImportTest::exportTest(bytes const& _output) |
| 555 | { |
| 556 | int err = 0; |
| 557 | if (m_testType == testType::GeneralStateTest) |
| 558 | { |
| 559 | vector<size_t> stateIndexesToPrint; |
| 560 | if (m_testObject.count("expect") > 0) |
| 561 | { |
| 562 | for (auto const& exp: m_testObject["expect"].get_array()) |
| 563 | checkGeneralTestSection(exp.get_obj(), stateIndexesToPrint); |
| 564 | m_testObject.erase(m_testObject.find("expect")); |
| 565 | } |
| 566 | |
| 567 | size_t k = 0; |
| 568 | std::map<string, json_spirit::mArray> postState; |
| 569 | for(size_t i = 0; i < m_transactions.size(); i++) |
| 570 | { |
| 571 | json_spirit::mObject obj; |
| 572 | json_spirit::mObject obj2; |
| 573 | obj["data"] = m_transactions[i].dataInd; |
| 574 | obj["gas"] = m_transactions[i].gasInd; |
| 575 | obj["value"] = m_transactions[i].valInd; |
| 576 | obj2["indexes"] = obj; |
| 577 | obj2["hash"] = toHex(m_transactions[i].postState.rootHash().asBytes()); |
| 578 | if (stateIndexesToPrint.size()) |
| 579 | if (i == stateIndexesToPrint[k] && Options::get().checkstate) |
| 580 | { |
| 581 | obj2["postState"] = fillJsonWithState(m_transactions[i].postState); |
| 582 | k++; |
| 583 | } |
| 584 | postState[netIdToString(m_transactions[i].netId)].push_back(obj2); |
| 585 | } |
| 586 | |
| 587 | json_spirit::mObject obj; |
| 588 | for(std::map<string, json_spirit::mArray>::iterator it = postState.begin(); it != postState.end(); ++it) |
| 589 | obj[it->first] = it->second; |
| 590 | |
| 591 | m_testObject["post"] = obj; |
| 592 | } |
| 593 | else |
| 594 | { |
| 595 | |
| 596 | // export output |
| 597 | m_testObject["out"] = (_output.size() > 4096 && !Options::get().fulloutput) ? "#" + toString(_output.size()) : toHex(_output, 2, HexPrefix::Add); |
| 598 | |
| 599 | // compare expected output with post output |
| 600 | if (m_testObject.count("expectOut") > 0) |
| 601 | { |
| 602 | std::string warning = "Check State: Error! Unexpected output: " + m_testObject["out"].get_str() + " Expected: " + m_testObject["expectOut"].get_str(); |
| 603 | if (Options::get().checkstate) |
| 604 | { |
| 605 | bool statement = (m_testObject["out"].get_str() == m_testObject["expectOut"].get_str()); |
| 606 | BOOST_CHECK_MESSAGE(statement, warning); |
| 607 | if (!statement) |
| 608 | err = 1; |
| 609 | } |
| 610 | else |
| 611 | BOOST_WARN_MESSAGE(m_testObject["out"].get_str() == m_testObject["expectOut"].get_str(), warning); |
no test coverage detected