Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
duniter
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pascal Engélibert
duniter
Commits
78be018c
Commit
78be018c
authored
Jul 19, 2013
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Amendments can be parsed/generated
parent
ad25ab39
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/models/amendment.js
+32
-0
32 additions, 0 deletions
app/models/amendment.js
doc/TODO
+2
-2
2 additions, 2 deletions
doc/TODO
test/amendments.js
+6
-0
6 additions, 0 deletions
test/amendments.js
with
40 additions
and
2 deletions
app/models/amendment.js
+
32
−
0
View file @
78be018c
var
jpgp
=
require
(
'
../lib/jpgp
'
);
var
mongoose
=
require
(
'
mongoose
'
);
var
async
=
require
(
'
async
'
);
var
sha1
=
require
(
'
sha1
'
);
var
_
=
require
(
'
underscore
'
);
var
Schema
=
mongoose
.
Schema
;
...
...
@@ -17,6 +18,7 @@ var AmendmentSchema = new Schema({
membersRoot
:
String
,
membersCount
:
String
,
membersChanges
:
Array
,
hash
:
String
,
created
:
Date
,
updated
:
Date
});
...
...
@@ -60,6 +62,7 @@ AmendmentSchema.methods = {
callback
(
"
No amendment given
"
);
return
;
}
this
.
hash
=
sha1
(
rawAmend
).
toUpperCase
();
var
obj
=
this
;
var
captures
=
[
{
prop
:
"
version
"
,
regexp
:
/Version:
(
.*
)
/
},
...
...
@@ -204,6 +207,35 @@ AmendmentSchema.methods = {
}
}
return
voters
;
},
getRaw
:
function
()
{
var
raw
=
""
;
raw
+=
"
Version:
"
+
this
.
version
+
"
\n
"
;
raw
+=
"
Currency:
"
+
this
.
currency
+
"
\n
"
;
raw
+=
"
Number:
"
+
this
.
number
+
"
\n
"
;
if
(
this
.
previousHash
){
raw
+=
"
PreviousHash:
"
+
this
.
previousHash
+
"
\n
"
;
}
if
(
this
.
dividend
){
raw
+=
"
UniversalDividend:
"
+
this
.
dividend
+
"
\n
"
;
}
if
(
this
.
coinMinPower
){
raw
+=
"
CoinMinimalPower:
"
+
this
.
coinMinPower
+
"
\n
"
;
}
raw
+=
"
VotersRoot:
"
+
this
.
votersRoot
+
"
\n
"
;
raw
+=
"
VotersCount:
"
+
this
.
votersCount
+
"
\n
"
;
raw
+=
"
VotersChanges:
\n
"
;
for
(
var
j
=
0
;
j
<
this
.
votersChanges
.
length
;
j
++
){
raw
+=
this
.
votersChanges
[
j
]
+
"
\n
"
;
}
raw
+=
"
MembersRoot:
"
+
this
.
membersRoot
+
"
\n
"
;
raw
+=
"
MembersCount:
"
+
this
.
membersCount
+
"
\n
"
;
raw
+=
"
MembersChanges:
\n
"
;
for
(
var
i
=
0
;
i
<
this
.
membersChanges
.
length
;
i
++
){
raw
+=
this
.
membersChanges
[
i
]
+
"
\n
"
;
}
return
raw
;
}
};
...
...
This diff is collapsed.
Click to expand it.
doc/TODO
+
2
−
2
View file @
78be018c
...
...
@@ -19,8 +19,8 @@ Protocol implementation:
2) Managing Amendment submission:
✔ REST service to view root certificates used to initialize Amendment Chain - udc/amendments/init @done (13-07-12 23:55)
☐
REST service for receiving an Amendment data structure - udc/amendments/submit
☐
Check Amendment structure
✔
REST service for receiving an Amendment data structure - udc/amendments/submit
@done (13-07-19 21:43)
✔
Check Amendment structure
@done (13-07-19 21:43)
☐ Check Amendment eligibility according to the Node rules (notably UD amount)
☐ Store Amendment as available for voting
...
...
This diff is collapsed.
Click to expand it.
test/amendments.js
+
6
−
0
View file @
78be018c
...
...
@@ -2,6 +2,7 @@ var should = require('should');
var
assert
=
require
(
'
assert
'
);
var
fs
=
require
(
'
fs
'
);
var
mongoose
=
require
(
'
mongoose
'
);
var
sha1
=
require
(
'
sha1
'
);
var
nodecoin
=
require
(
'
../app/lib/nodecoin
'
);
...
...
@@ -73,6 +74,11 @@ describe('Amendment', function(){
assert
.
equal
(
newVoters
[
1
],
"
33BBFC0C67078D72AF128B5BA296CC530126F372
"
);
assert
.
equal
(
newVoters
[
2
],
"
C73882B64B7E72237A2F460CE9CAB76D19A8651E
"
);
});
it
(
'
its hash should be 6F4ACBC7A25A0AAB9B58778EAD5A297EF3E51D00
'
,
function
(){
assert
.
equal
(
amTest
.
hash
,
'
6F4ACBC7A25A0AAB9B58778EAD5A297EF3E51D00
'
);
assert
.
equal
(
sha1
(
amTest
.
getRaw
()).
toUpperCase
(),
'
6F4ACBC7A25A0AAB9B58778EAD5A297EF3E51D00
'
);
});
});
describe
(
'
1 of beta_brousouf currency
'
,
function
(){
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment