Governance: Validation 7: Blockchain Account Tests Completed

This commit is contained in:
Luis Fernando Molina committed 2021-08-24 14:11:45 +02:00
1 parent 81d2e6ae72
commit b2bac7e88a
1 file changed
+50 -48
+50 -48
View File
@@ -445,7 +445,7 @@ exports.newGithubServer = function newGithubServer() {
*/
if (userProfile.name !== githubUsername) {
console.log('[INFO] Github Server -> mergeGithubPullRequests -> Validation #5 Failed -> Pull Request "' + pullRequest.title + '" not merged because the Github Username is not equal to the User Profile node\'s name. -> Github Username = ' + githubUsername + '-> userProfile.name = ' + userProfile.name)
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.issues.createComment({
owner: owner,
@@ -514,64 +514,66 @@ exports.newGithubServer = function newGithubServer() {
}
async function validateUserProfileBlockchainAccountDoesNotBelongtoAnotherUserProfile() {
/*
Validation #7 The blockchain account of the User Profile can not be the
blockchain account of an already existing User Profile
unless the existing one belongs to the same Github username.
*/
let userProfileIdMap = new Map()
let pluginFileNames = await CL.projects.foundations.utilities.plugins.getPluginFileNames(
'Governance',
'User-Profiles'
)
for (let i = 0; i < pluginFileNames.length; i++) {
let pluginFileName = pluginFileNames[i]
let pluginFileContent = await CL.projects.foundations.utilities.plugins.getPluginFileContent(
try {
/*
Validation #7 The blockchain account of the User Profile can not be the
blockchain account of an already existing User Profile
unless the existing one belongs to the same Github username.
*/
let userProfileIdMap = new Map()
let pluginFileNames = await CL.projects.foundations.utilities.plugins.getPluginFileNames(
'Governance',
'User-Profiles',
pluginFileName
'User-Profiles'
)
for (let i = 0; i < pluginFileNames.length; i++) {
let pluginFileName = pluginFileNames[i]
let pluginFileContent = await CL.projects.foundations.utilities.plugins.getPluginFileContent(
'Governance',
'User-Profiles',
pluginFileName
)
let otherUserProfile = JSON.parse(pluginFileContent)
let otherUserProfile = JSON.parse(pluginFileContent)
let config = JSON.parse(otherUserProfile.config)
let messageSigned = config.signature.message
let config = JSON.parse(otherUserProfile.config)
let messageSigned = JSON.stringify(config.signature)
let serverResponse = await CL.servers.WEB3_SERVER.recoverAddress(
messageSigned
)
userProfileIdMap.set(serverResponse.address, otherUserProfile.name)
}
let config = JSON.parse(userProfile.config)
let messageSigned = JSON.stringify(config.signature)
let serverResponse = await CL.servers.WEB3_SERVER.recoverAddress(
messageSigned
)
userProfileIdMap.set(serverResponse.address, otherUserProfile.name)
}
let testUserProfile = userProfileIdMap.get(serverResponse.address)
if (testUserProfile === undefined) { return true }
if (testUserProfile !== userProfile.name) {
let config = JSON.parse(userProfile.config)
let messageSigned = config.signature.message
let serverResponse = await CL.servers.WEB3_SERVER.recoverAddress(
messageSigned
)
console.log('[INFO] Github Server -> mergeGithubPullRequests -> Validation #7 Failed -> Pull Request "' + pullRequest.title + '" not merged because the User Profile Blockchain Account already exists and belongs to another User Profile on record. -> Profile Blockchain Account = ' + serverResponse.address + '-> User Profile with the same Blockchain Account = ' + testUserProfile)
let testUserProfile = userProfileIdMap.get(serverResponse.address)
if (testUserProfile === undefined) { return true }
if (testUserProfile !== userProfile.name) {
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: pullRequest.number,
body: 'This Pull Request could not be automatically merged and was closed by the Superalgos Governance System because the User Profile Blockchain Account already exists and belongs to another User Profile on record. \n\nUser Profile Blockchain Account = "' + serverResponse.address + '" \n\n User Profile with the same Blockchain Account = "' + testUserProfile + '"'
});
console.log('[INFO] Github Server -> mergeGithubPullRequests -> Validation #7 Failed -> Pull Request "' + pullRequest.title + '" not merged because the User Profile Blockchain Account already exists and belongs to another User Profile on record. -> Profile Blockchain Account = ' + serverResponse.address + '-> User Profile with the same Blockchain Account = ' + testUserProfile)
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: pullRequest.number,
body: 'This Pull Request could not be automatically merged and was closed by the Superalgos Governance System because the User Profile Blockchain Account already exists and belongs to another User Profile on record. \n\nUser Profile Blockchain Account = "' + serverResponse.address + '" \n\n User Profile with the same Blockchain Account = "' + testUserProfile + '"'
});
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.pulls.update({
owner: owner,
repo: repo,
pull_number: pullRequest.number,
state: 'closed'
});
return false
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.pulls.update({
owner: owner,
repo: repo,
pull_number: pullRequest.number,
state: 'closed'
});
return false
}
} catch (err) {
console.log(err.stack)
}
}