Skip to content

Commit

Permalink
Revert "Evaluation is responsible to enforce casing (#550)"
Browse files Browse the repository at this point in the history
This reverts commit a0ec7dd.
  • Loading branch information
Ptroger committed Oct 3, 2024
1 parent a0ec7dd commit 4f13e2a
Show file tree
Hide file tree
Showing 38 changed files with 289 additions and 807 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package main

test_approversRoles {
roles = approversRoles with input as requestWithEip1559Transaction with data.entities as entities
roles == {"root", "member", "admin"}
}

test_approversGroups {
groups = approversGroups with input as requestWithEip1559Transaction with data.entities as entities
groups == {"test-user-group-one-uid", "test-user-group-two-uid"}
}

test_checkApprovalByUserId {
requiredApproval = {
"approvalCount": 2,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
package main

import data.armory.lib.chainAccount.build

test_source {
res = build.intentSourceChainAccount(input.intent) with input as requestWithEip1559Transaction with data.entities as entities
res = getIntentSourceChainAccount(input.intent) with input as requestWithEip1559Transaction with data.entities as entities

expected := {
"id": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98E",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98E",
res == {
"id": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chainId": 137,
"classification": "managed",
"accountType": "eoa",
"assignees": ["test-bOb-uid", "test-alicE-uid", "test-foo-uid", "test-bar-uid"],
"groups": {"test-account-group-ONE-uid"},
"assignees": ["test-bob-uid", "test-alice-uid", "test-foo-uid", "test-bar-uid"],
"accountGroups": {"test-account-group-one-uid"},
}

expected == res

checkSourceId({"eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"}) with input as requestWithEip1559Transaction with data.entities as entities
checkSourceAddress({"0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"}) with input as requestWithEip1559Transaction with data.entities as entities
checkSourceAccountType({"eoa"}) with input as requestWithEip1559Transaction with data.entities as entities
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package main

import data.armory.entities.get

test_principal {
user = get.user(input.principal.userId) with input as requestWithEip1559Transaction with data.entities as entities
user = principal with input as requestWithEip1559Transaction with data.entities as entities
user == {"id": "test-bob-uid", "role": "root"}

user == {"id": "test-BOB-uid", "role": "root", "groups": {"test-USER-group-one-uid", "test-USER-group-two-uid"}}
groups = principalGroups with input as requestWithEip1559Transaction with data.entities as entities
groups == {"test-user-group-one-uid", "test-user-group-two-uid"}

checkPrincipalId({"test-bob-uid", "test-alice-uid"}) with input as requestWithEip1559Transaction with data.entities as entities
checkPrincipalRole({"root", "admin"}) with input as requestWithEip1559Transaction with data.entities as entities
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package main

import data.armory.entities.get

test_resource {
account = get.account(input.resource.uid) with input as requestWithEip1559Transaction with data.entities as entities

expected := {
"id": "eip155:eoa:0xDDcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208F219a6e6af072f2cfdc615b2c1805f98e",
account = resource with input as requestWithEip1559Transaction with data.entities as entities
account == {
"id": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-bOb-uid", "test-alicE-uid", "test-foo-uid", "test-bar-uid"],
"groups": {"test-account-group-ONE-uid"},
"assignees": ["test-bob-uid", "test-alice-uid", "test-foo-uid", "test-bar-uid"],
}
account == expected

checkAccountId({"eip155:eoa:0xdDcF208f219a6e6af072f2cfdc615b2c1805F98E"}) with input as requestWithEip1559Transaction with data.entities as entities
checkAccountAddress({"0xdDCf208f219a6e6af072f2cfdc615b2c1805f98e"}) with input as requestWithEip1559Transaction with data.entities as entities
groups = accountGroups with input as requestWithEip1559Transaction with data.entities as entities
groups == {"test-account-group-one-uid"}

accountGroupsById = getAccountGroups("eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e") with input as requestWithEip1559Transaction with data.entities as entities
accountGroupsById == {"test-account-group-one-uid"}

checkAccountId({"eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"}) with input as requestWithEip1559Transaction with data.entities as entities
checkAccountAddress({"0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"}) with input as requestWithEip1559Transaction with data.entities as entities
checkAccountType({"eoa"}) with input as requestWithEip1559Transaction with data.entities as entities
checkAccountGroup({"teST-account-groUp-one-uid"}) with input as requestWithEip1559Transaction with data.entities as entities
checkAccountGroup({"test-account-group-one-uid"}) with input as requestWithEip1559Transaction with data.entities as entities
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ tenHoursAgo = (nowSeconds - ((10 * 60) * 60)) * 1000 # in ms

nineHoursAgo = (nowSeconds - ((9 * 60) * 60)) * 1000 # in ms

principalReq = {"userId": "test-bob-Uid"}
principalReq = {"userId": "test-bob-uid"}

resourceReq = {"uid": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98E"}
resourceReq = {"uid": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e"}

transactionRequestEIP1559 = {
"from": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98E",
"to": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7A3",
"from": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"to": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"chainId": 137,
"maxFeePerGas": "20000000000",
"maxPriorityFeePerGas": "3000000000",
Expand All @@ -38,30 +38,30 @@ transactionRequestEIP1559 = {
}

transactionRequestLegacy = {
"from": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98E",
"to": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7A3",
"from": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"to": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"chainId": 137,
"gas": "21000",
"gasPrice": "20000000000",
"value": "0xde0b6b3A7640000",
"value": "0xde0b6b3a7640000",
"data": "0x00000000",
"nonce": 192,
"type": "0",
}

intentReq = {
"type": "transferERC20",
"from": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98E",
"to": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7A3",
"token": "eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aA84174",
"from": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"to": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"token": "eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
"amount": "1000000000000000000", # 1 USDC
}

approvalsReq = [
{"userId": "test-bob-uiD"},
{"userId": "test-alice-uiD"},
{"userId": "test-foo-uiD"},
{"userId": "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2A43"},
{"userId": "test-bob-uid"},
{"userId": "test-alice-uid"},
{"userId": "test-foo-uid"},
{"userId": "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43"},
]

feedsReq = [
Expand Down Expand Up @@ -143,82 +143,82 @@ requestWithLegacyTransaction = {
entities = {
"addressBook": {
"eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3": {
"id": "eip155:137:0xA45E21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"address": "0xa45e21E9370Ba031c5e1f47dedca74a7ce2ed7a3",
"id": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"address": "0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"chainId": 137,
"classification": "internal",
},
"eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"id": "eip155:137:0xDDcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddCF208f219a6e6af072f2cfdc615b2c1805f98e",
"id": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chainId": 137,
"classification": "managed",
},
"eip155:1:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"id": "eip155:1:0xDDCf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208F219a6e6af072f2cfdc615b2c1805f98e",
"id": "eip155:1:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"chainId": 1,
"classification": "managed",
},
},
"tokens": {"eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174": {
"id": "eip155:137/erc20:0x2791bCA1f2de4661ed88a30c99a7a9449aa84174",
"address": "0x2791bca1f2de4661ED88a30c99a7a9449aa84174",
"id": "eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
"address": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
"symbol": "USDC",
"chainId": 137,
"decimals": 6,
}},
"users": {
"test-bob-uid": {
"id": "test-BOB-uid",
"id": "test-bob-uid",
"role": "root",
},
"test-alice-uid": {
"id": "test-Alice-uid",
"id": "test-alice-uid",
"role": "member",
},
"test-bar-uid": {
"id": "test-Bar-uid",
"id": "test-bar-uid",
"role": "admin",
},
"test-foo-uid": {
"id": "test-Foo-uid",
"id": "test-foo-uid",
"role": "admin",
},
"0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43": {
"id": "0xAAA8ee1cbaa1856f4550c6fc24abb16c5c9b2a43",
"id": "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43",
"role": "admin",
},
},
"userGroups": {
"test-user-group-one-uid": {
"id": "test-USER-group-one-uid",
"id": "test-user-group-one-uid",
"name": "dev",
"users": ["test-Bob-uid", "test-Bar-uid"],
"users": ["test-bob-uid", "test-bar-uid"],
},
"test-user-group-two-uid": {
"id": "test-USER-group-two-uid",
"id": "test-user-group-two-uid",
"name": "finance",
"users": ["tesT-Bob-uid", "test-bar-uid"],
"users": ["test-bob-uid", "test-bar-uid"],
},
},
"accounts": {
"eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e": {
"id": "eip155:eoa:0xDDcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208F219a6e6af072f2cfdc615b2c1805f98e",
"id": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-bOb-uid", "test-alicE-uid", "test-foo-uid", "test-bar-uid"],
"assignees": ["test-bob-uid", "test-alice-uid", "test-foo-uid", "test-bar-uid"],
},
"eip155:eoa:0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e": {
"id": "eip155:eoa:0xbbbb208f219a6e6af072F2cfdc615b2c1805f98e",
"address": "0xbbbb208f219a6e6af072f2cfdC615b2c1805f98e",
"id": "eip155:eoa:0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e",
"address": "0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e",
"accountType": "eoa",
"assignees": ["test-Bob-uid", "test-alicE-uid", "test-foo-uid", "test-bar-uid", "0xAAA8ee1cbaa1856f4550c6fc24abb16c5c9b2a43"],
"assignees": ["test-bob-uid", "test-alice-uid", "test-foo-uid", "test-bar-uid", "0xaaa8ee1cbaa1856f4550c6fc24abb16c5c9b2a43"],
},
},
"accountGroups": {"test-account-group-one-uid": {
"id": "test-account-group-ONE-uid",
"id": "test-account-group-one-uid",
"name": "dev",
"accounts": ["eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e", "eip155:eoa:0xbbBB208f219a6e6af072f2cfdc615b2c1805f98e"],
"accounts": ["eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e", "eip155:eoa:0xbbbb208f219a6e6af072f2cfdc615b2c1805f98e"],
}},
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ permit[{"policyId": "approvalByUserGroups"}] = reason {
checkIntentAmount(transferValueCondition)

approvals = checkApprovals(approvalsRequired)

reason = {
"type": "permit",
"policyId": "approvalByUserGroups",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test_approvalByUserGroups {

res = permit[{"policyId": "approvalByUserGroups"}] with input as approvalByUserGroupsReq with data.entities as entities

expected := {
res == {
"approvalsMissing": [],
"approvalsSatisfied": [{
"approvalCount": 2,
Expand All @@ -46,7 +46,6 @@ test_approvalByUserGroups {
"policyId": "approvalByUserGroups",
"type": "permit",
}
res == expected
}

test_approvalByUserRoles {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ forbid[{"policyId": "spendingLimitByUserGroup"}] = reason {
},
"filters": {"userGroups": {"test-user-group-one-uid"}},
})

reason = {
"type": "forbid",
"policyId": "spendingLimitByUserGroup",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
package main

import data.armory.lib.chainAccount.build.extractAddressFromAccountId

test_transformIntentToTransferObject {
res = transformIntentToTransferObject(input.intent) with input as requestWithEip1559Transaction with data.entities as entities

expected := {
res == {
"amount": "1000000000000000000",
"chainId": 137,
"from": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98E",
"initiatedBy": "test-bob-Uid",
"from": "eip155:137:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"initiatedBy": "test-bob-uid",
"rates": {"fiat:eur": "1.10", "fiat:usd": "0.99"},
"resourceId": "eip155:eoa:0xDDcf208f219a6e6af072f2cfdc615b2c1805f98e",
"resourceId": "eip155:eoa:0xddcf208f219a6e6af072f2cfdc615b2c1805f98e",
"timestamp": nowSeconds * 1000,
"to": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7A3",
"token": "eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aA84174",
"to": "eip155:137:0xa45e21e9370ba031c5e1f47dedca74a7ce2ed7a3",
"token": "eip155:137/erc20:0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
}
res == expected
}

test_parseUnits {
Expand Down
Loading

0 comments on commit 4f13e2a

Please sign in to comment.