Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/onchain testdata #129

Merged
merged 15 commits into from
Mar 1, 2024
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"clean": "rm -fR dist",
"build": "npm run clean && ./node_modules/.bin/tsc --strictNullChecks",
"test": "./node_modules/.bin/mocha --timeout 5000 -p -r ts-node/register 'test/**/*.test.ts'"
vmidyllic marked this conversation as resolved.
Show resolved Hide resolved
"test": "./node_modules/.bin/mocha --timeout 5000 -r ts-node/register 'test/**/*.test.ts'"
},
"license": "GPL-3.0",
"dependencies": {
Expand Down
56 changes: 28 additions & 28 deletions test/onchain/credentialAtomicQueryV3OnChain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {describe} from "mocha";
const path = require("path");
const wasmTester = require("circom_tester").wasm;

describe("Test credentialAtomicQueryV3OnChain.circom", function () {
describe.only("Test credentialAtomicQueryV3OnChain.circom", function () {
volodymyr-basiuk marked this conversation as resolved.
Show resolved Hide resolved

this.timeout(600000);

Expand All @@ -30,35 +30,35 @@ describe("Test credentialAtomicQueryV3OnChain.circom", function () {
const tests = [

// sig
require(`${sigBasePath}/claimIssuedOnProfileID.json`),
require(`${sigBasePath}/claimIssuedOnProfileID2.json`),
require(`${sigBasePath}/claimIssuedOnUserID.json`),
require(`${sigBasePath}/profileID_subject_userid.json`),
require(`${sigBasePath}/claimNonMerklized.json`),
require(`${sigBasePath}/claimWithLinkNonce.json`),
require(`${sigBasePath}/between_operator.json`),
require(`${sigBasePath}/less_than_eq_operator.json`),
require(`${sigBasePath}/selective_disclosure.json`),
require(`${sigBasePath}/nullify.json`),
require(`${sigBasePath}/revoked_claim_without_revocation_check.json`),
require(`${sigBasePath}/jsonld_non_inclusion.json`),
require(`${sigBasePath}/auth_check_disabled.json`),
require(`${sigBasePath}/noop_operator.json`),
// require(`${sigBasePath}/claimIssuedOnProfileID.json`),
// require(`${sigBasePath}/claimIssuedOnProfileID2.json`),
// require(`${sigBasePath}/claimIssuedOnUserID.json`),
// require(`${sigBasePath}/profileID_subject_userid.json`),
// require(`${sigBasePath}/claimNonMerklized.json`),
// require(`${sigBasePath}/claimWithLinkNonce.json`),
// require(`${sigBasePath}/between_operator.json`),
// require(`${sigBasePath}/less_than_eq_operator.json`),
// require(`${sigBasePath}/selective_disclosure.json`),
// require(`${sigBasePath}/nullify.json`),
// require(`${sigBasePath}/revoked_claim_without_revocation_check.json`),
// require(`${sigBasePath}/jsonld_non_inclusion.json`),
// require(`${sigBasePath}/noop_operator.json`),
require(`${sigBasePath}/onchainIdentity.json`),

// mtp
require(`${mtpBasePath}/claimIssuedOnProfileID.json`),
require(`${mtpBasePath}/claimIssuedOnProfileID2.json`),
require(`${mtpBasePath}/claimIssuedOnUserID.json`),
require(`${mtpBasePath}/profileID_subject_userid.json`),
require(`${mtpBasePath}/claimNonMerklized.json`),
require(`${mtpBasePath}/claimWithLinkNonce.json`),
require(`${mtpBasePath}/between_operator.json`),
require(`${mtpBasePath}/less_than_eq_operator.json`),
require(`${mtpBasePath}/selective_disclosure.json`),
require(`${mtpBasePath}/nullify.json`),
require(`${mtpBasePath}/revoked_claim_without_revocation_check.json`),
require(`${mtpBasePath}/auth_check_disabled.json`),
require(`${mtpBasePath}/noop_operator.json`),
// require(`${mtpBasePath}/claimIssuedOnProfileID.json`),
// require(`${mtpBasePath}/claimIssuedOnProfileID2.json`),
// require(`${mtpBasePath}/claimIssuedOnUserID.json`),
// require(`${mtpBasePath}/profileID_subject_userid.json`),
// require(`${mtpBasePath}/claimNonMerklized.json`),
// require(`${mtpBasePath}/claimWithLinkNonce.json`),
// require(`${mtpBasePath}/between_operator.json`),
// require(`${mtpBasePath}/less_than_eq_operator.json`),
// require(`${mtpBasePath}/selective_disclosure.json`),
// require(`${mtpBasePath}/nullify.json`),
// require(`${mtpBasePath}/revoked_claim_without_revocation_check.json`),
// require(`${mtpBasePath}/noop_operator.json`),
// require(`${mtpBasePath}/onchainIdentity.json`),
];

tests.forEach(({ desc, inputs, expOut }) => {
Expand Down
30 changes: 23 additions & 7 deletions testvectorgen/contract_data/generate_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,11 @@ type TestDataSigV2 struct {

func Test_Generate_Test_Cases(t *testing.T) {

id, issuerFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis state", "issuer_genesis_state")
nextId, userFirstState := generateStateTransitionData(t, false, UserPK, IssuerPK, "User from genesis transition", "user_state_transition")
id, issuerFirstState := generateStateTransitionData(t, false, IssuerPK, UserPK, "Issuer from genesis state", "issuer_genesis_state", false, false)
nextId, userFirstState := generateStateTransitionData(t, false, UserPK, IssuerPK, "User from genesis transition", "user_state_transition", false, false)

generateStateTransitionData(t, true, IssuerPK, UserPK, "Issuer next transition state", "issuer_next_state_transition")
generateStateTransitionData(t, true, UserPK, IssuerPK, "User next transition state", "user_next_state_transition")
generateStateTransitionData(t, true, IssuerPK, UserPK, "Issuer next transition state", "issuer_next_state_transition", false, false)
generateStateTransitionData(t, true, UserPK, IssuerPK, "User next transition state", "user_next_state_transition", false, false)

generateMTPData(t, "MTP: Issuer first state", []*gistData{
{id, issuerFirstState},
Expand Down Expand Up @@ -272,10 +272,19 @@ type gistData struct {
state *big.Int
}

func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, secondaryPK, desc, fileName string) (*big.Int, *big.Int) {
func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, secondaryPK, desc, fileName string, isSubjectIDProfile bool, isEthBased bool) (*big.Int, *big.Int) {

var err error
primaryEntity := utils.NewIdentity(t, primaryPK)
secondaryEntity := utils.NewIdentity(t, secondaryPK)

var secondaryEntity *utils.IdentityTest

if !isEthBased {
secondaryEntity = utils.NewIdentity(t, secondaryPK)
} else {
// generate onchain identity
secondaryEntity = utils.NewEthereumBasedIdentity(t, ethAddress)
}

isGenesis := "1"
// user
Expand All @@ -291,7 +300,14 @@ func generateStateTransitionData(t *testing.T, nextState bool, primaryPK, second
//if genesis == false {
// extract pubKey

_, secondaryEntityClaim := utils.DefaultJSONUserClaim(t, secondaryEntity.ID)
subjectID := secondaryEntity.ID
if isSubjectIDProfile {
nonceSubject := big.NewInt(999)
subjectID, err = core.ProfileID(secondaryEntity.ID, nonceSubject)
require.NoError(t, err)
}

_, secondaryEntityClaim := utils.DefaultJSONNormalUserClaim(t, subjectID)
primaryEntity.AddClaim(t, secondaryEntityClaim)

if nextState {
Expand Down
Loading
Loading