-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathget_metadatav6_ok.cpp
63 lines (46 loc) · 1.65 KB
/
get_metadatav6_ok.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "../src/polkadot.h"
#include "helpers/mockjsonrpc.h"
#undef NDEBUG
#include <cassert>
class CMockJsonRpcMissingField : public CMockJsonRpcMD0 {
private:
virtual Json getMetadata() {
string testValue;
string line;
ifstream myfile("test/metadata/exampleMetadataV6.txt");
if (myfile.is_open()) {
while (getline(myfile, line)) {
testValue += line;
}
myfile.close();
}
string err;
return Json("0x" + testValue);
}
};
int main(int argc, char *argv[]) {
EasyLogger log;
CMockJsonRpcMissingField mockRpc;
CPolkaApi app(&log, &mockRpc);
app.connect();
string blockHash = "0x37096ff58d1831c2ee64b026f8b70afab1942119c022d1dcfdbdc1558ebf63fa";
unique_ptr<GetMetadataParams> par2(new GetMetadataParams);
strcpy(par2->blockHash, blockHash.c_str());
auto resp2 = app.getMetadata(move(par2));
cout << endl << endl << endl;
if (resp2->metadataV0 != nullptr)
cout << "V0 first attr - " << resp2->metadataV0->module[0]->module.name << endl;
if (resp2->metadataV5 != nullptr)
cout << "V5 first attr - " << resp2->metadataV5->module[0]->name << endl;
if (resp2->metadataV6 != nullptr)
cout << "V6 first attr - " << resp2->metadataV6->module[0]->name << endl;
// metadataV0 is not set here
assert(resp2->metadataV0 == nullptr);
// metadataV5 is not set here
assert(resp2->metadataV5 == nullptr);
// metadataV5 parsed successfully, in other case it would be nullptr
assert(resp2->metadataV6 != nullptr);
app.disconnect();
cout << "success" << endl;
return 0;
}