Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dunixir
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
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
teaching
dunixir
Commits
0749a76b
Commit
0749a76b
authored
Jan 7, 2022
by
ROUSSET Noemie
Browse files
Options
Downloads
Patches
Plain Diff
rule BR_G74 - Identity pubkey unicity - code + tests
parent
0c263250
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/local_augmentation_example.ex
+6
-0
6 additions, 0 deletions
lib/local_augmentation_example.ex
test/identity/augmentation/identity_pub_key_unicity_test.exs
+57
-0
57 additions, 0 deletions
test/identity/augmentation/identity_pub_key_unicity_test.exs
with
63 additions
and
0 deletions
lib/local_augmentation_example.ex
+
6
−
0
View file @
0749a76b
...
...
@@ -377,6 +377,12 @@ defmodule Index.Augmentation do
[{
_key
,
entry
}]
=
:ets
.
lookup
(
local_iindex
,
key
)
entry
.
uidUnique
==
true
end
## BR_G74
def
identityPubkeyUnicity
(
local_iindex
,
key
)
do
[{
_key
,
entry
}]
=
:ets
.
lookup
(
local_iindex
,
key
)
entry
.
pubUnique
==
true
end
end
defmodule
MIndex
do
...
...
This diff is collapsed.
Click to expand it.
test/identity/augmentation/identity_pub_key_unicity_test.exs
0 → 100644
+
57
−
0
View file @
0749a76b
defmodule
IdentityPubKeyUnicityTest
do
use
ExUnit
.
Case
doctest
Index
.
Augmentation
.
IIndex
setup_all
do
local_iindex
=
:ets
.
new
(
:local_iindex
,
[
:set
,
:protected
])
local_mindex
=
:ets
.
new
(
:local_mindex
,
[
:set
,
:protected
])
#we create 2 new local identities in the local iindex
Index
.
Generation
.
add_identity
(
"blockstamp_test"
,
local_iindex
,
local_mindex
,
%{
"pub"
=>
"pub_toto"
,
"block_uid"
=>
"block_uid_test"
,
"user_id"
=>
"user_id_toto"
})
Index
.
Generation
.
add_identity
(
"blockstamp_test"
,
local_iindex
,
local_mindex
,
%{
"pub"
=>
"pub_tata"
,
"block_uid"
=>
"block_uid_test"
,
"user_id"
=>
"user_id_tata"
})
#we copy these identities into the global iindex table
{
:ok
,
global_iindex
}
=
:dets
.
open_file
(
:"test/global_iindex"
,
type:
:set
)
:ets
.
to_dets
(
local_iindex
,
global_iindex
)
#we replace the public key pub_toto to pub_tutu in the global iindex
[{
"pub_toto"
,
elt
}]
=
:dets
.
lookup
(
global_iindex
,
"pub_toto"
)
:dets
.
delete
(
global_iindex
,
"pub_toto"
)
new_elt
=
Map
.
replace!
(
elt
,
:pub
,
"pub_tutu"
)
:dets
.
insert
(
global_iindex
,
{
"pub_tutu"
,
new_elt
})
#we search if the local iindex is not found in the global iindex with op="CREATE"
#toto.pubUnique is set to true
Index
.
Augmentation
.
IIndex
.
pubUnique
(
local_iindex
,
global_iindex
,
"pub_toto"
)
#tata.pubUnique is set to false
Index
.
Augmentation
.
IIndex
.
pubUnique
(
local_iindex
,
global_iindex
,
"pub_tata"
)
:dets
.
close
(
global_iindex
)
:file
.
delete
(
"test/global_iindex"
)
#check if the public key is unique or not
pubKeyUniqueTrue
=
Index
.
Augmentation
.
IIndex
.
identityPubkeyUnicity
(
local_iindex
,
"pub_toto"
)
pubKeyUniqueFalse
=
Index
.
Augmentation
.
IIndex
.
identityPubkeyUnicity
(
local_iindex
,
"pub_tata"
)
{
:ok
,
pubKeyUniqueTrue:
pubKeyUniqueTrue
,
pubKeyUniqueFalse:
pubKeyUniqueFalse
}
end
test
"check pubUnique is the right value"
,
state
do
assert
state
.
pubKeyUniqueTrue
==
true
assert
state
.
pubKeyUniqueFalse
==
false
end
end
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