Electroneum
Loading...
Searching...
No Matches
ringdb.cpp File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <boost/filesystem.hpp>
#include "gtest/gtest.h"
#include "string_tools.h"
#include "crypto/crypto.h"
#include "crypto/random.h"
#include "crypto/chacha.h"
#include "ringct/rctOps.h"
#include "cryptonote_basic/cryptonote_basic.h"
#include "wallet/ringdb.h"
Include dependency graph for ringdb.cpp:

Go to the source code of this file.

Classes

class  RingDB

Functions

 TEST (ringdb, not_found)
 TEST (ringdb, found)
 TEST (ringdb, convert)
 TEST (ringdb, different_genesis)
 TEST (spent_outputs, not_found)
 TEST (spent_outputs, found)
 TEST (spent_outputs, vector)
 TEST (spent_outputs, mark_as_unspent)
 TEST (spent_outputs, clear)

Function Documentation

◆ TEST() [1/9]

TEST ( ringdb ,
convert  )

Definition at line 117 of file ringdb.cpp.

118{
119 RingDB ringdb;
120 std::vector<uint64_t> outs, outs2;
121 outs.push_back(43); outs.push_back(7320); outs.push_back(8429);
122 ASSERT_TRUE(ringdb.set_ring(KEY_1, KEY_IMAGE_1, outs, true));
123 ASSERT_TRUE(ringdb.get_ring(KEY_1, KEY_IMAGE_1, outs2));
124 ASSERT_EQ(outs2.size(), 3);
125 ASSERT_EQ(outs2[0], 43);
126 ASSERT_EQ(outs2[1], 43+7320);
127 ASSERT_EQ(outs2[2], 43+7320+8429);
128}
bool set_ring(const crypto::chacha_key &chacha_key, const crypto::key_image &key_image, const std::vector< uint64_t > &outs, bool relative)
Definition ringdb.cpp:376
bool get_ring(const crypto::chacha_key &chacha_key, const crypto::key_image &key_image, std::vector< uint64_t > &outs)
Definition ringdb.cpp:340
#define ASSERT_EQ(val1, val2)
Definition gtest.h:1956
#define ASSERT_TRUE(condition)
Definition gtest.h:1865
Here is the call graph for this function:

◆ TEST() [2/9]

TEST ( ringdb ,
different_genesis  )

Definition at line 130 of file ringdb.cpp.

131{
132 RingDB ringdb;
133 std::vector<uint64_t> outs, outs2;
134 outs.push_back(43); outs.push_back(7320); outs.push_back(8429);
135 ASSERT_TRUE(ringdb.set_ring(KEY_1, KEY_IMAGE_1, outs, false));
136 ASSERT_FALSE(ringdb.get_ring(KEY_2, KEY_IMAGE_1, outs2));
137}
#define ASSERT_FALSE(condition)
Definition gtest.h:1868
Here is the call graph for this function:

◆ TEST() [3/9]

TEST ( ringdb ,
found  )

Definition at line 107 of file ringdb.cpp.

108{
109 RingDB ringdb;
110 std::vector<uint64_t> outs, outs2;
111 outs.push_back(43); outs.push_back(7320); outs.push_back(8429);
112 ASSERT_TRUE(ringdb.set_ring(KEY_1, KEY_IMAGE_1, outs, false));
113 ASSERT_TRUE(ringdb.get_ring(KEY_1, KEY_IMAGE_1, outs2));
114 ASSERT_EQ(outs, outs2);
115}
Here is the call graph for this function:

◆ TEST() [4/9]

TEST ( ringdb ,
not_found  )

Definition at line 100 of file ringdb.cpp.

101{
102 RingDB ringdb;
103 std::vector<uint64_t> outs;
104 ASSERT_FALSE(ringdb.get_ring(KEY_1, KEY_IMAGE_1, outs));
105}
Here is the call graph for this function:

◆ TEST() [5/9]

TEST ( spent_outputs ,
clear  )

Definition at line 185 of file ringdb.cpp.

186{
187 RingDB ringdb;
188 ASSERT_TRUE(ringdb.blackball(OUTPUT_1));
190 ASSERT_FALSE(ringdb.blackballed(OUTPUT_1));
191}
bool clear_blackballs()
Definition ringdb.cpp:491
bool blackball(const std::pair< uint64_t, uint64_t > &output)
Definition ringdb.cpp:473
bool blackballed(const std::pair< uint64_t, uint64_t > &output)
Definition ringdb.cpp:485
Here is the call graph for this function:

◆ TEST() [6/9]

TEST ( spent_outputs ,
found  )

Definition at line 146 of file ringdb.cpp.

147{
148 RingDB ringdb;
149 ASSERT_TRUE(ringdb.blackball(OUTPUT_1));
150 ASSERT_TRUE(ringdb.blackballed(OUTPUT_1));
151}
Here is the call graph for this function:

◆ TEST() [7/9]

TEST ( spent_outputs ,
mark_as_unspent  )

Definition at line 177 of file ringdb.cpp.

178{
179 RingDB ringdb;
180 ASSERT_TRUE(ringdb.blackball(OUTPUT_1));
181 ASSERT_TRUE(ringdb.unblackball(OUTPUT_1));
182 ASSERT_FALSE(ringdb.blackballed(OUTPUT_1));
183}
bool unblackball(const std::pair< uint64_t, uint64_t > &output)
Definition ringdb.cpp:479
Here is the call graph for this function:

◆ TEST() [8/9]

TEST ( spent_outputs ,
not_found  )

Definition at line 139 of file ringdb.cpp.

140{
141 RingDB ringdb;
142 ASSERT_TRUE(ringdb.blackball(OUTPUT_1));
143 ASSERT_FALSE(ringdb.blackballed(OUTPUT_2));
144}
Here is the call graph for this function:

◆ TEST() [9/9]

TEST ( spent_outputs ,
vector  )

Definition at line 153 of file ringdb.cpp.

154{
155 RingDB ringdb;
156 std::vector<std::pair<uint64_t, uint64_t>> outputs;
157 outputs.push_back(std::make_pair(0, 1));
158 outputs.push_back(std::make_pair(10, 3));
159 outputs.push_back(std::make_pair(10, 4));
160 outputs.push_back(std::make_pair(10, 8));
161 outputs.push_back(std::make_pair(20, 0));
162 outputs.push_back(std::make_pair(20, 1));
163 outputs.push_back(std::make_pair(30, 5));
164 ASSERT_TRUE(ringdb.blackball(outputs));
165 ASSERT_TRUE(ringdb.blackballed(std::make_pair(0, 1)));
166 ASSERT_FALSE(ringdb.blackballed(std::make_pair(10, 2)));
167 ASSERT_TRUE(ringdb.blackballed(std::make_pair(10, 3)));
168 ASSERT_TRUE(ringdb.blackballed(std::make_pair(10, 4)));
169 ASSERT_FALSE(ringdb.blackballed(std::make_pair(10, 5)));
170 ASSERT_TRUE(ringdb.blackballed(std::make_pair(10, 8)));
171 ASSERT_TRUE(ringdb.blackballed(std::make_pair(20, 0)));
172 ASSERT_TRUE(ringdb.blackballed(std::make_pair(20, 1)));
173 ASSERT_FALSE(ringdb.blackballed(std::make_pair(20, 2)));
174 ASSERT_TRUE(ringdb.blackballed(std::make_pair(30, 5)));
175}
Here is the call graph for this function: