Skip to content

Commit

Permalink
Removed domain fallback and fixed callback error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
bmastahac committed Jan 22, 2021
1 parent 711a475 commit 580be9a
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 25 deletions.
2 changes: 1 addition & 1 deletion bricking/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ const putBrick = (keySSI, brick, authToken, callback) => {
if (!err) {
err = new Error('Failed to create bricks in:' + brickStorageArray);
}
return callback(err);
return OpenDSUSafeCallback(callback)(createOpenDSUErrorWrapper("Failed to create bricks",err));
}

const foundBrick = results[0];
Expand Down
6 changes: 5 additions & 1 deletion resolver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ const createDSU = (templateKeySSI, options, callback) => {
return OpenDSUSafeCallback(callback)(createOpenDSUErrorWrapper(`Failed to create DSU instance`, err));
}

function addInCache(){
function addInCache(err, result){
if (err)
{
return OpenDSUSafeCallback(callback)(createOpenDSUErrorWrapper(`Failed to create DSU instance`, err));
}
addDSUInstanceInCache(dsuInstance, callback);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const resolver = require('../../resolver');
const keySSI = require("../../keyssi")


assert.callback('Create DSU on custom domain', (testfinished) => {
assert.callback('Create DSU on already configured domain', (testfinished) => {

dc.createTestFolder('createDSU',(err,folder) => {
testIntegration.launchApiHubTestNode(10, folder, (err) => {
Expand All @@ -17,8 +17,7 @@ assert.callback('Create DSU on custom domain', (testfinished) => {
throw err;
}

const domain = 'testdomain';
prepareBDNSContext(folder);
const domain = 'default';
createdsu(domain ,(err, keySSI, dsuHashLink) => {

loadDsuAndCheck(err, keySSI, dsuHashLink, () => {
Expand All @@ -34,30 +33,11 @@ assert.callback('Create DSU on custom domain', (testfinished) => {

}, 5000);

function prepareBDNSContext(folder)
{

let bdns = {
'testdomain': {
"replicas": [],
"brickStorages": [
"$ORIGIN"
],
"anchoringServices": [
"$ORIGIN"
]
}
}

require('fs').writeFileSync(folder+'/external-volume/config/bdns.hosts', JSON.stringify(bdns));

}


function createdsu(domain, keySSICallback)
{
const keyssitemplate = keySSI.buildTemplateKeySSI('seed',domain);
resolver.createDSU(keyssitemplate, {bricksDomain: domain}, (err, dsu) => {
resolver.createDSU(keyssitemplate,(err, dsu) => {
if (err)
{
throw err;
Expand Down
60 changes: 60 additions & 0 deletions tests/resolver/CreateDSUWillFailOnPartialSupportedDomain.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require("../../../../psknode/bundles/testsRuntime");
const testIntegration = require("../../../../psknode/tests/util/tir");

const dc = require("double-check");
const assert = dc.assert;

const resolver = require('../../resolver');
const keySSI = require("../../keyssi")


assert.callback('Create DSU on partial supported domain will fail', (testfinished) => {

dc.createTestFolder('createDSU',(err,folder) => {
testIntegration.launchApiHubTestNode(10, folder, (err) => {
const domain = 'testdomain';
prepareBDNSContext(folder);
createDSU(domain ,(err, dus) => {

printOpenDSUError(err);
assert.notEqual(typeof err,'undefined');

testfinished();

});
})
})




}, 5000);


function createDSU(domain, callback)
{
const keyssitemplate = keySSI.buildTemplateKeySSI('seed',domain);
resolver.createDSU(keyssitemplate, {bricksDomain: domain}, (err, dsu) => {
callback(err, dsu);
});
}


function prepareBDNSContext(folder)
{

let bdns = {
'testdomain': {
"replicas": [],
"brickStorages": [
"$ORIGIN"
],
"anchoringServices": [
"$ORIGIN"
]
}
}

require('fs').writeFileSync(folder+'/external-volume/config/bdns.hosts', JSON.stringify(bdns));

}

0 comments on commit 580be9a

Please sign in to comment.