Browse Source

use config dump and update tests

Kieran Gibb 2 years ago
parent
commit
80956f85c8
No known key found for this signature in database
2 changed files with 12 additions and 1 deletions
  1. 1
    1
      index.js
  2. 11
    0
      test/index.test.js

+ 1
- 1
index.js View File

@@ -159,7 +159,7 @@ class GroupStore {
159 159
   }
160 160
 
161 161
   _saveGroup (group) {
162
-    this.config.groups.set(group.address, group._attributes())
162
+    this.config.groups.set(group.address, group.toConfig())
163 163
     var success = this.config.save()
164 164
     if (!success) return false
165 165
     return true

+ 11
- 0
test/index.test.js View File

@@ -46,6 +46,7 @@ describe('group store: basic', (context) => {
46 46
       config = Config(storage),
47 47
       params = Object.assign(crypto.keySet(), { name: 'magma' })
48 48
 
49
+    seedConfig()
49 50
     config.groups.set(params.address, params)
50 51
 
51 52
     const store = Store(Decrypted, storage, { config })
@@ -62,6 +63,16 @@ describe('group store: basic', (context) => {
62 63
     assert.ok(group, 'finds a group')
63 64
     assert.same(group && group.address, params.address, 'finds the correct group')
64 65
     cleanup(storage, next)
66
+
67
+    function seedConfig () {
68
+      var group1 = Object.assign(crypto.keySet(), { name: 'cobox' }),
69
+        group2 = Object.assign(crypto.keySet(), { name: 'iuvia' }),
70
+        group3 = Object.assign(crypto.keySet(), { name: 'blockades' })
71
+
72
+      config.groups.set(group1.address, group1)
73
+      config.groups.set(group2.address, group2)
74
+      config.groups.set(group3.address, group3)
75
+    }
65 76
   })
66 77
 
67 78
   context('where({ name, address: null })', async function (assert, next) {