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
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
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
nodes
typescript
duniter
Commits
597bd3e6
Commit
597bd3e6
authored
8 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
Fix #472 Old pending transactions never removed
parent
c3f803ee
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/lib/dal/sqliteDAL/TxsDAL.js
+8
-4
8 additions, 4 deletions
app/lib/dal/sqliteDAL/TxsDAL.js
test/integration/transactions-pruning.js
+67
-0
67 additions, 0 deletions
test/integration/transactions-pruning.js
with
75 additions
and
4 deletions
app/lib/dal/sqliteDAL/TxsDAL.js
+
8
−
4
View file @
597bd3e6
...
...
@@ -110,22 +110,26 @@ function TxsDAL(db) {
this
.
getLinkedWithIssuer
=
(
pubkey
)
=>
this
.
sqlFind
({
issuers
:
{
$contains
:
pubkey
},
written
:
true
written
:
true
,
removed
:
false
});
this
.
getLinkedWithRecipient
=
(
pubkey
)
=>
this
.
sqlFind
({
recipients
:
{
$contains
:
pubkey
},
written
:
true
written
:
true
,
removed
:
false
});
this
.
getPendingWithIssuer
=
(
pubkey
)
=>
this
.
sqlFind
({
issuers
:
{
$contains
:
pubkey
},
written
:
false
written
:
false
,
removed
:
false
});
this
.
getPendingWithRecipient
=
(
pubkey
)
=>
this
.
sqlFind
({
recipients
:
{
$contains
:
pubkey
},
written
:
false
written
:
false
,
removed
:
false
});
this
.
insertBatchOfTxs
=
(
txs
)
=>
co
(
function
*
()
{
...
...
This diff is collapsed.
Click to expand it.
test/integration/transactions-pruning.js
0 → 100644
+
67
−
0
View file @
597bd3e6
"
use strict
"
;
const
co
=
require
(
'
co
'
);
const
should
=
require
(
'
should
'
);
const
user
=
require
(
'
./tools/user
'
);
const
commit
=
require
(
'
./tools/commit
'
);
const
until
=
require
(
'
./tools/until
'
);
const
toolbox
=
require
(
'
./tools/toolbox
'
);
const
Peer
=
require
(
'
../../app/lib/entity/peer
'
);
const
s1
=
toolbox
.
server
({
currency
:
'
currency_one
'
,
dt
:
600
,
pair
:
{
pub
:
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
,
sec
:
'
51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP
'
}
});
const
cat1
=
user
(
'
cat
'
,
{
pub
:
'
HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
,
sec
:
'
51w4fEShBk1jCMauWu4mLpmDVfHksKmWcygpxriqCEZizbtERA6de4STKRkQBpxmMUwsKXRjSzuQ8ECwmqN1u2DP
'
},
{
server
:
s1
});
const
tac1
=
user
(
'
tac
'
,
{
pub
:
'
2LvDg21dVXvetTD9GdkPLURavLYEqP3whauvPWX4c2qc
'
,
sec
:
'
2HuRLWgKgED1bVio1tdpeXrf7zuUszv1yPHDsDj7kcMC4rVSN9RC58ogjtKNfTbH1eFz7rn38U1PywNs3m6Q7UxE
'
},
{
server
:
s1
});
describe
(
"
Transactions pruning
"
,
function
()
{
before
(()
=>
co
(
function
*
()
{
yield
s1
.
prepareForNetwork
();
const
now
=
parseInt
(
Date
.
now
()
/
1000
);
// Publishing identities
yield
cat1
.
createIdentity
();
yield
tac1
.
createIdentity
();
yield
cat1
.
cert
(
tac1
);
yield
tac1
.
cert
(
cat1
);
yield
cat1
.
join
();
yield
tac1
.
join
();
yield
s1
.
commit
();
yield
s1
.
commit
({
time
:
now
+
1300
});
yield
s1
.
commit
();
yield
cat1
.
send
(
20
,
tac1
);
yield
cat1
.
send
(
100
,
tac1
);
}));
it
(
'
double spending transactions should both exist first
'
,
()
=>
s1
.
expect
(
'
/tx/history/HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
,
(
res
)
=>
{
res
.
history
.
should
.
have
.
property
(
'
sending
'
).
length
(
2
);
}));
it
(
'
should only commit 1 tx
'
,
()
=>
co
(
function
*
()
{
yield
s1
.
commit
();
yield
s1
.
expect
(
'
/blockchain/block/2
'
,
(
res
)
=>
{
res
.
should
.
have
.
property
(
'
transactions
'
).
length
(
0
);
});
yield
s1
.
expect
(
'
/blockchain/block/3
'
,
(
res
)
=>
{
res
.
should
.
have
.
property
(
'
transactions
'
).
length
(
1
);
});
}));
it
(
'
double spending transaction should have been pruned
'
,
()
=>
co
(
function
*
()
{
yield
s1
.
commit
();
yield
s1
.
expect
(
'
/tx/history/HgTTJLAQ5sqfknMq7yLPZbehtuLSsKj9CxWN7k8QvYJd
'
,
(
res
)
=>
{
res
.
history
.
should
.
have
.
property
(
'
sending
'
).
length
(
0
);
});
}));
});
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
register
or
sign in
to comment