Skip to content
Snippets Groups Projects
Commit 35751f70 authored by benjamin's avatar benjamin
Browse files

god kill me

parent edb401b2
No related branches found
No related tags found
1 merge request!60Revert "Fail a test to be sure it works"
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
cryptoChannel "gitlab.com/elixxir/crypto/channel" cryptoChannel "gitlab.com/elixxir/crypto/channel"
"gitlab.com/elixxir/xxdk-wasm/storage" "gitlab.com/elixxir/xxdk-wasm/storage"
"syscall/js" "syscall/js"
"time"
"gitlab.com/elixxir/client/channels" "gitlab.com/elixxir/client/channels"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
...@@ -93,6 +94,26 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher, ...@@ -93,6 +94,26 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher,
return nil, err return nil, err
} }
// Save the encryption status to storage
encryptionStatus := encryption != nil
loadedEncryptionStatus, err := storage.StoreIndexedDbEncryptionStatus(
databaseName, encryptionStatus)
if err != nil {
return nil, err
}
// Verify encryption status does not change
if encryptionStatus != loadedEncryptionStatus {
return nil, errors.New(
"Cannot load database with different encryption status.")
} else if !encryptionStatus {
jww.WARN.Printf("IndexedDb encryption disabled!")
}
// Attempt to ensure the database has been properly initialized
var wrapper *wasmModel
for shittyError := errors.New("dummy"); shittyError != nil; {
// FIXME: The below is a hack that for some reason prevents moving on with // FIXME: The below is a hack that for some reason prevents moving on with
// uninitialized database despite the previous call to Await. // uninitialized database despite the previous call to Await.
// It would be idea to find a different solution. // It would be idea to find a different solution.
...@@ -113,25 +134,14 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher, ...@@ -113,25 +134,14 @@ func newWASMModel(databaseName string, encryption cryptoChannel.Cipher,
if err != nil { if err != nil {
return nil, err return nil, err
} }
wrapper = &wasmModel{db: db, receivedMessageCB: cb, cipher: encryption}
// Save the encryption status to storage shittyError = wrapper.hackTestDb()
encryptionStatus := encryption != nil if shittyError != nil {
loadedEncryptionStatus, err := storage.StoreIndexedDbEncryptionStatus( jww.ERROR.Println(shittyError)
databaseName, encryptionStatus)
if err != nil {
return nil, err
} }
time.Sleep(1 * time.Second)
// Verify encryption status does not change
if encryptionStatus != loadedEncryptionStatus {
return nil, errors.New(
"Cannot load database with different encryption status.")
} else if !encryptionStatus {
jww.WARN.Printf("IndexedDb encryption disabled!")
} }
// Attempt to ensure the database has been properly initialized
wrapper := &wasmModel{db: db, receivedMessageCB: cb, cipher: encryption}
return wrapper, nil return wrapper, nil
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment