                                                           :from addr2}))))
           (testing "Correct increase of the bid is accepted"
             (is (auction-offering/bid! {:offering/address offering}
-                                       {:value (web3/to-wei 0.2 :ether)
+                                       {:value bid-value-user-2
                                         :from addr2})))
           (let [balance-of-2 (web3-eth/get-balance @web3 addr2)]
             (testing "Arbitrary increase of the bid is ok"

                               {:from addr0})))
    (testing "Offering the name with overdue endtime fails"
      (is (thrown? :default (auction-offering-factory/create-offering!
                              {:offering/name "abc.eth"
                               :offering/price (eth->wei 0.1)
                               :auction-offering/end-time (to-epoch (time/minus (now) (time/seconds 1)))
                               :auction-offering/extension-duration 0
                               :auction-offering/min-bid-increase (web3/to-wei 0.1 :ether)}
                              {:from addr0}))))
    (testing "Offering the name with 0 bidincrease fails"
      (is (thrown? :default (auction-offering-factory/create-offering!
                              {:offering/name "abc.eth"
                               :offering/price (eth->wei 0.1)
                               :auction-offering/end-time (to-epoch (time/plus (now) (time/weeks 1)))
                               :auction-offering/extension-duration 0
                               :auction-offering/min-bid-increase (web3/to-wei 0 :ether)}
                              {:from addr0}))))
    (let [tx-hash (auction-offering-factory/create-offering!
                    {:offering/name "abc.eth"
                     :offering/price (eth->wei 0.1)
                     :auction-offering/end-time (to-epoch (time/plus (now) (time/weeks 2)))
                     :auction-offering/extension-duration 0
                     :auction-offering/min-bid-increase (web3/to-wei 0.1 :ether)}
                    {:from addr0})]
      (testing "Offering the name for a bid"
        (is tx-hash))

      (let [{{:keys [:offering]} :args}
            (offering-registry/on-offering-added-in-tx tx-hash {:node (namehash "abc.eth")
                                                                :from-block 0
                                                                :owner addr0})]
        (testing "on-offering event should fire"
          (is (not (nil? offering))))
        (when offering

              (is (= addr3 (registrar/entry-deed-owner {:ens.record/label "abc"}))))

            (testing "User who was overbid, getting his funds back from auction offering."
              ;; Note: transaction costs don't apply, `balance-of-2` is tracked after the bid
              (let [expected-balance (bn/+ balance-of-2 bid-value-user-2)
                    actual-balance (web3-eth/get-balance @web3 addr2)]
                (is (bn/zero? (bn/- expected-balance actual-balance)))))))))))


(deftest offering-tld-ownership
