| 44 | |
| 45 | } |
| 46 | void testscriptdb() { |
| 47 | vector<unsigned char> vScriptId = {0x01,0x00,0x00,0x00,0x01,0x00}; |
| 48 | vector<unsigned char> vScriptId1 = {0x01,0x00,0x00,0x00,0x02,0x00}; |
| 49 | vector<unsigned char> vScriptContent = {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}; |
| 50 | vector<unsigned char> vScriptContent1 = {0x01,0x02,0x03,0x04,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01}; |
| 51 | CRegID regScriptId(vScriptId); |
| 52 | CRegID regScriptId1(vScriptId1); |
| 53 | //write script content to db |
| 54 | BOOST_CHECK(pTestView->SetContractScript(regScriptId, vScriptContent)); |
| 55 | BOOST_CHECK(pTestView->SetContractScript(regScriptId1, vScriptContent1)); |
| 56 | //write all data in caches to db |
| 57 | BOOST_CHECK(pTestView->Flush()); |
| 58 | //test if the script id is exist in db |
| 59 | BOOST_CHECK(pTestView->HasContract(regScriptId)); |
| 60 | vector<unsigned char> vScript; |
| 61 | //read script content from db by scriptId |
| 62 | BOOST_CHECK(pTestView->GetContractScript(regScriptId, vScript)); |
| 63 | // if the readed script content equals with original |
| 64 | BOOST_CHECK(vScriptContent == vScript); |
| 65 | int nCount; |
| 66 | //get script numbers from db |
| 67 | // BOOST_CHECK(pTestView->GetScriptCount(nCount)); |
| 68 | //if the number is one |
| 69 | BOOST_CHECK_EQUAL(nCount, 2); |
| 70 | //get index 0 script from db |
| 71 | vScript.clear(); |
| 72 | vector<unsigned char> vId; |
| 73 | //delete script from db |
| 74 | BOOST_CHECK(pTestView->EraseContractScript(regScriptId)); |
| 75 | // BOOST_CHECK(pTestView->GetScriptCount(nCount)); |
| 76 | BOOST_CHECK_EQUAL(nCount, 1); |
| 77 | //write all data in caches to db |
| 78 | BOOST_CHECK(pTestView->Flush()); |
| 79 | } |
| 80 | |
| 81 | void settodb(int nType, vector<unsigned char> &vKey, vector<unsigned char> &vScriptData) { |
| 82 | vector<unsigned char> vScriptId = {0x01,0x00,0x00,0x00,0x02,0x00}; |
no test coverage detected