Skip to content

Commit

Permalink
Remove comma from splits (#1274)
Browse files Browse the repository at this point in the history
Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
Bushstar and prasannavl authored May 24, 2022
1 parent 576503a commit a5407dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
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

0 comments on commit a5407dd

Please sign in to comment.