Skip to content

:db/add rejected when equivalent to db.fn/call + #12

@moea

Description

@moea
(deftest scratch-passing
  (common/deployed-valid-invariant? backend schema)
  (let [txn [[:db.fn/call + 1 :account/balance -1]
             [:db.fn/call + 2 :account/balance +1]
             [:db/add 1 :transaction/signed-by 1]]]
    (is (not (common/balance-mismatch? backend txn schema)))))

(defn balance [u]
  (:account/balance (d/entity @conn u)))

(deftest scratch-failing
  (common/deployed-valid-invariant? backend schema)
  (let [txn [[:db/add 1 :account/balance (dec (balance 1))]
             [:db/add 2 :account/balance (inc (balance 2))]
             [:db/add 1 :transaction/signed-by 1]]]
    (is (not (common/balance-mismatch? backend txn schema)))))

@whilo It looks like ?balance-change is equivalent to ?balance-after in the second case, so the tx is rejected, though it's equivalent to the first (passing) tx. For commutativity etc. there's reasons why the first is preferable, and I may be missing something - but it seems like the second form ought to be acceptable?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions