Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove comma from splits #1274

Merged
merged 2 commits into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/masternodes/govvariables/attributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,11 @@ UniValue ATTRIBUTES::ExportFiltered(GovVarsFilter filter, const std::string &pre
ret.pushKV(key, result);
} else if (const auto splitValues = boost::get<OracleSplits>(&attribute.second)) {
std::string keyValue;
for (const auto& [tokenId, multiplier] : *splitValues) {
keyValue += KeyBuilder(tokenId, multiplier) + ',';
for (auto it{splitValues->begin()}; it != splitValues->end(); ++it) {
if (it != splitValues->begin()) {
keyValue += ',';
}
keyValue += KeyBuilder(it->first, it->second);
}
ret.pushKV(key, keyValue);
} else if (const auto& descendantPair = boost::get<DescendantValue>(&attribute.second)) {
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_setgov.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ def run_test(self):
self.nodes[0].setgov({"ATTRIBUTES":{f'v0/token/4/fixed_interval_price_id':'TSLA/USD', f'v0/token/4/loan_minting_enabled':'true', f'v0/token/4/loan_minting_interest':'1'}})
self.nodes[0].generate(1)

self.nodes[0].setgov({"ATTRIBUTES":{'v0/oracles/splits/4000':'4/50,5/5,'}})
self.nodes[0].setgov({"ATTRIBUTES":{'v0/oracles/splits/4000':'4/50,5/5'}})
self.nodes[0].generate(1)

# Check auto lock
Expand All @@ -710,7 +710,7 @@ def run_test(self):
self.nodes[0].generate(1)

attriutes = self.nodes[0].getgov('ATTRIBUTES')['ATTRIBUTES']
assert_equal(attriutes['v0/oracles/splits/4000'], '4/50,5/10,')
assert_equal(attriutes['v0/oracles/splits/4000'], '4/50,5/10')

if __name__ == '__main__':
GovsetTest ().main ()
8 changes: 4 additions & 4 deletions test/functional/feature_token_split.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,9 @@ def check_govvar_deletion(self):

# Check splits
result = self.nodes[0].listgovs()[8][0]['ATTRIBUTES']
assert_equal(result[f'v0/oracles/splits/{split_height}'], f'{self.idTSLA}/2,')
assert_equal(result[f'v0/oracles/splits/500000'], f'{self.idTSLA}/2,')
assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idTSLA}/2,{self.idNVDA}/2,')
assert_equal(result[f'v0/oracles/splits/{split_height}'], f'{self.idTSLA}/2')
assert_equal(result[f'v0/oracles/splits/500000'], f'{self.idTSLA}/2')
assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idTSLA}/2,{self.idNVDA}/2')

# Split
self.nodes[0].generate(1)
Expand All @@ -629,7 +629,7 @@ def check_govvar_deletion(self):
result = self.nodes[0].listgovs()[8][0]['ATTRIBUTES']
assert(f'v0/oracles/splits/{split_height}' not in result)
assert(f'v0/oracles/splits/500000' not in result)
assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idNVDA}/2,')
assert_equal(result[f'v0/oracles/splits/1000000'], f'{self.idNVDA}/2')

# Swap old for new values
self.idTSLA = list(self.nodes[0].gettoken(self.symbolTSLA).keys())[0]
Expand Down