Skip to content

Commit

Permalink
modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
demonsh committed May 26, 2022
1 parent 8abfca1 commit 9000b8c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
10 changes: 6 additions & 4 deletions credentialAtomicQueryMTPWithRelay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func TestAtomicQueryMTPWithRelay_PrepareInputs(t *testing.T) {
query := Query{
SlotIndex: 2,
Values: []*big.Int{new(big.Int).SetInt64(10)},
Operator: 0,
Operator: EQ,
}

atomicInputs := AtomicQueryMTPWithRelayInputs{
Expand All @@ -183,7 +183,8 @@ func TestAtomicQueryMTPWithRelay_PrepareInputs(t *testing.T) {
expectedJSONInputs := `{"userAuthClaim":["304427537360709784173770334266246861770","0",
"17640206035128972995519606214765283372613874593503528180869261482403155458945",
"20634138280259599560273310290025659992320584624461316485434108770067472477956","15930428023331155902","0","0","0"],
"userAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtpAuxHi":"0","userAuthClaimNonRevMtpAuxHv":"0","userAuthClaimNonRevMtpNoAux":"1","userClaimsTreeRoot":"9763429684850732628215303952870004997159843236039795272605841029866455670219","userRevTreeRoot":"0","userRootsTreeRoot":"0","userID":"379949150130214723420589610911161895495647789006649785264738141299135414272","challenge":"1","challengeSignatureR8x":"8553678144208642175027223770335048072652078621216414881653012537434846327449","challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709","challengeSignatureS":"2093461910575977345603199789919760192811763972089699387324401771367839603655","issuerClaim":["3583233690122716044519380227940806650830","379949150130214723420589610911161895495647789006649785264738141299135414272","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimIdenState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimMtp":["0","0","18337129644116656308842422695567930755039142442806278977230099338026575870840","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimNonRevClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerID":"26599707002460144379092755370384635496563807452878989192352627271768342528","operator":0,"slotIndex":2,"timestamp":"1642074362","value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"relayProofValidClaimsTreeRoot":"8121168901305742662057879845808052431346752743553205352641990714922661618462","relayProofValidRevTreeRoot":"0","relayProofValidRootsTreeRoot":"0","relayState":"4239448240735161374561925497474400621823161116770305241717998726622296721696","userStateInRelayClaim":["795467278703584189433295357807347445218","379949150130214723420589610911161895495647789006649785264738141299135414272","0","0","0","0","18656147546666944484453899241916469544090258810192803949522794490493271005313","0"],"userStateInRelayClaimMtp":["12411413272899006501067884001808071121528224140660538219214791597550929401851","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}`
"userAuthClaimMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0",
"0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"userAuthClaimNonRevMtpAuxHi":"0","userAuthClaimNonRevMtpAuxHv":"0","userAuthClaimNonRevMtpNoAux":"1","userClaimsTreeRoot":"9763429684850732628215303952870004997159843236039795272605841029866455670219","userRevTreeRoot":"0","userRootsTreeRoot":"0","userID":"379949150130214723420589610911161895495647789006649785264738141299135414272","challenge":"1","challengeSignatureR8x":"8553678144208642175027223770335048072652078621216414881653012537434846327449","challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709","challengeSignatureS":"2093461910575977345603199789919760192811763972089699387324401771367839603655","issuerClaim":["3583233690122716044519380227940806650830","379949150130214723420589610911161895495647789006649785264738141299135414272","10","0","30803922965249841627828060161","0","0","0"],"issuerClaimClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimIdenState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimMtp":["0","0","18337129644116656308842422695567930755039142442806278977230099338026575870840","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimRevTreeRoot":"0","issuerClaimRootsTreeRoot":"0","issuerClaimNonRevClaimsTreeRoot":"3077200351284676204723270374054827783313480677490603169533924119235084704890","issuerClaimNonRevRevTreeRoot":"0","issuerClaimNonRevRootsTreeRoot":"0","issuerClaimNonRevState":"18605292738057394742004097311192572049290380262377486632479765119429313092475","issuerClaimNonRevMtp":["0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"issuerClaimNonRevMtpAuxHi":"0","issuerClaimNonRevMtpAuxHv":"0","issuerClaimNonRevMtpNoAux":"1","claimSchema":"180410020913331409885634153623124536270","issuerID":"26599707002460144379092755370384635496563807452878989192352627271768342528","operator":1,"slotIndex":2,"timestamp":"1642074362","value":["10","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"],"relayProofValidClaimsTreeRoot":"8121168901305742662057879845808052431346752743553205352641990714922661618462","relayProofValidRevTreeRoot":"0","relayProofValidRootsTreeRoot":"0","relayState":"4239448240735161374561925497474400621823161116770305241717998726622296721696","userStateInRelayClaim":["795467278703584189433295357807347445218","379949150130214723420589610911161895495647789006649785264738141299135414272","0","0","0","0","18656147546666944484453899241916469544090258810192803949522794490493271005313","0"],"userStateInRelayClaimMtp":["12411413272899006501067884001808071121528224140660538219214791597550929401851","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"]}`

var actualInputs map[string]interface{}
err = json.Unmarshal(inputsJSON, &actualInputs)
Expand Down Expand Up @@ -280,15 +281,16 @@ func TestAtomicQueryMTPWithRelayOutputs_CircuitUnmarshal(t *testing.T) {
Challenge: big.NewInt(1),
ClaimSchema: schema,
SlotIndex: 2,
Operator: 0,
Operator: EQ,
Values: values,
Timestamp: int64(1642074362),
IssuerID: issuerID,
}

out := new(AtomicQueryMTPWithRelayPubSignals)
err = out.PubSignalsUnmarshal([]byte(
`["379949150130214723420589610911161895495647789006649785264738141299135414272", "4239448240735161374561925497474400621823161116770305241717998726622296721696", "1", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "0", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`))
`["379949150130214723420589610911161895495647789006649785264738141299135414272",
"4239448240735161374561925497474400621823161116770305241717998726622296721696", "1", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "1", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`))

assert.NoError(t, err)
assert.Equal(t, expectedOut, *out)
Expand Down
9 changes: 5 additions & 4 deletions credentialAtomicQueryMTP_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func TestAtomicQuery_PrepareInputs(t *testing.T) {
query := Query{
SlotIndex: 2,
Values: []*big.Int{new(big.Int).SetInt64(10)},
Operator: 0,
Operator: EQ,
}

atomicInputs := AtomicQueryMTPInputs{
Expand All @@ -161,7 +161,7 @@ func TestAtomicQuery_PrepareInputs(t *testing.T) {
bytesInputs, err := atomicInputs.InputsMarshal()
assert.Nil(t, err)

expectedJSONInputs := `{ "userAuthClaim": [ "304427537360709784173770334266246861770", "0", "17640206035128972995519606214765283372613874593503528180869261482403155458945", "20634138280259599560273310290025659992320584624461316485434108770067472477956", "15930428023331155902", "0", "0", "0" ], "userAuthClaimMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtpAuxHi": "0", "userAuthClaimNonRevMtpAuxHv": "0", "userAuthClaimNonRevMtpNoAux": "1", "userClaimsTreeRoot": "9763429684850732628215303952870004997159843236039795272605841029866455670219", "userState": "18656147546666944484453899241916469544090258810192803949522794490493271005313", "userRevTreeRoot": "0", "userRootsTreeRoot": "0", "userID": "379949150130214723420589610911161895495647789006649785264738141299135414272", "challenge": "1", "challengeSignatureR8x": "8553678144208642175027223770335048072652078621216414881653012537434846327449", "challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709", "challengeSignatureS": "2093461910575977345603199789919760192811763972089699387324401771367839603655", "issuerClaim": [ "3583233690122716044519380227940806650830", "379949150130214723420589610911161895495647789006649785264738141299135414272", "10", "0", "30803922965249841627828060161", "0", "0", "0" ], "issuerClaimClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimIdenState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimMtp": [ "0", "0", "18337129644116656308842422695567930755039142442806278977230099338026575870840", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimRevTreeRoot": "0", "issuerClaimRootsTreeRoot": "0", "issuerClaimNonRevClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimNonRevRevTreeRoot": "0", "issuerClaimNonRevRootsTreeRoot": "0", "issuerClaimNonRevState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimNonRevMtpAuxHi": "0", "issuerClaimNonRevMtpAuxHv": "0", "issuerClaimNonRevMtpNoAux": "1", "claimSchema": "180410020913331409885634153623124536270", "issuerID": "26599707002460144379092755370384635496563807452878989192352627271768342528", "operator": 0, "slotIndex": 2, "timestamp": "1642074362", "value": [ "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ] }`
expectedJSONInputs := `{ "userAuthClaim": [ "304427537360709784173770334266246861770", "0","17640206035128972995519606214765283372613874593503528180869261482403155458945", "20634138280259599560273310290025659992320584624461316485434108770067472477956", "15930428023331155902", "0", "0", "0" ], "userAuthClaimMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "userAuthClaimNonRevMtpAuxHi": "0", "userAuthClaimNonRevMtpAuxHv": "0", "userAuthClaimNonRevMtpNoAux": "1", "userClaimsTreeRoot": "9763429684850732628215303952870004997159843236039795272605841029866455670219", "userState": "18656147546666944484453899241916469544090258810192803949522794490493271005313", "userRevTreeRoot": "0", "userRootsTreeRoot": "0", "userID": "379949150130214723420589610911161895495647789006649785264738141299135414272", "challenge": "1", "challengeSignatureR8x": "8553678144208642175027223770335048072652078621216414881653012537434846327449", "challengeSignatureR8y":"5507837342589329113352496188906367161790372084365285966741761856353367255709", "challengeSignatureS": "2093461910575977345603199789919760192811763972089699387324401771367839603655", "issuerClaim": [ "3583233690122716044519380227940806650830", "379949150130214723420589610911161895495647789006649785264738141299135414272", "10", "0", "30803922965249841627828060161", "0", "0", "0" ], "issuerClaimClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimIdenState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimMtp": [ "0", "0", "18337129644116656308842422695567930755039142442806278977230099338026575870840", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimRevTreeRoot": "0", "issuerClaimRootsTreeRoot": "0", "issuerClaimNonRevClaimsTreeRoot": "3077200351284676204723270374054827783313480677490603169533924119235084704890", "issuerClaimNonRevRevTreeRoot": "0", "issuerClaimNonRevRootsTreeRoot": "0", "issuerClaimNonRevState": "18605292738057394742004097311192572049290380262377486632479765119429313092475", "issuerClaimNonRevMtp": [ "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ], "issuerClaimNonRevMtpAuxHi": "0", "issuerClaimNonRevMtpAuxHv": "0", "issuerClaimNonRevMtpNoAux": "1", "claimSchema": "180410020913331409885634153623124536270", "issuerID": "26599707002460144379092755370384635496563807452878989192352627271768342528", "operator": 1, "slotIndex": 2, "timestamp": "1642074362", "value": [ "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0" ] }`

assert.JSONEq(t, expectedJSONInputs, string(bytesInputs))

Expand Down Expand Up @@ -208,13 +208,14 @@ func TestAtomicQueryMTPOutputs_CircuitUnmarshal(t *testing.T) {
IssuerID: issuerID,
SlotIndex: 2,
Values: values,
Operator: 0,
Operator: EQ,
Timestamp: timestamp,
}

out := new(AtomicQueryMTPPubSignals)
err = out.PubSignalsUnmarshal([]byte(
`["379949150130214723420589610911161895495647789006649785264738141299135414272", "18656147546666944484453899241916469544090258810192803949522794490493271005313", "1", "18605292738057394742004097311192572049290380262377486632479765119429313092475", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "0", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`))
`["379949150130214723420589610911161895495647789006649785264738141299135414272",
"18656147546666944484453899241916469544090258810192803949522794490493271005313", "1", "18605292738057394742004097311192572049290380262377486632479765119429313092475", "26599707002460144379092755370384635496563807452878989192352627271768342528", "1642074362", "180410020913331409885634153623124536270", "2", "1", "10", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "9999"]`))
assert.NoError(t, err)

assert.Equal(t, expectedOut, *out)
Expand Down
Loading

0 comments on commit 9000b8c

Please sign in to comment.